2017-01-21 17:06:19 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
function get(u){return new Promise(function(r,t,a){a=new XMLHttpRequest();a.onload=function(b,c){b=a.status;c=a.response;if(b>199&&b<300){r(c)}else{t(c)}};a.open("GET",u,true);a.send(null)})}
|
|
|
|
|
2017-06-26 16:53:18 +00:00
|
|
|
/**
|
|
|
|
* Clamps x to be between min and max.
|
|
|
|
* @param {number} x The number to clamp.
|
|
|
|
* @param {number} min The minimum allowed value.
|
|
|
|
* @param {number} max The maximum allowed value.
|
|
|
|
* @return {number} The clamped number.
|
|
|
|
*/
|
|
|
|
function clamp(x, min, max)
|
|
|
|
{
|
|
|
|
if(x < min) return min;
|
|
|
|
if(x > max) return max;
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
2017-01-21 17:06:19 +00:00
|
|
|
export {
|
2017-06-26 16:53:18 +00:00
|
|
|
get,
|
|
|
|
clamp
|
2017-01-21 17:06:19 +00:00
|
|
|
};
|