1
0
Fork 0
mirror of https://github.com/sbrl/Nibriboard.git synced 2018-01-10 21:33:49 +00:00
Nibriboard/Nibriboard/ClientFiles/Utilities.js

23 lines
566 B
JavaScript
Raw Normal View History

"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;
}
export {
2017-06-26 16:53:18 +00:00
get,
clamp
};