Skip to content

Instantly share code, notes, and snippets.

View alsciende's full-sized avatar

Alsciende alsciende

View GitHub Profile
function interpolate(interpolation_data, new_value) {
var keys = Object.keys(interpolation_data),
min_value = Math.min.apply(Math, keys),
max_value = Math.max.apply(Math, keys),
min_image = interpolation_data[min_value],
max_image = interpolation_data[max_value];
return min_image + (max_image - min_image) * (new_value - min_value) / (max_value - min_value);
}
// when level = level_max, we get max PI
function doTwoThings() {
return new Promise(function (resolve, reject) {
doSomething()
.then(doSomethingElse)
.then(resolve, reject)
})
}