open-vault/ui/app/utils/clamp.js
2018-04-03 09:16:57 -05:00

10 lines
216 B
JavaScript

export default function(num, min, max) {
let inRangeNumber;
if (typeof num !== 'number') {
inRangeNumber = min;
} else {
inRangeNumber = num;
}
return Math.min(Math.max(inRangeNumber, min), max);
}