Add is.inRange() (#3)

This commit is contained in:
gui 2017-09-25 20:20:06 +01:00 committed by Sindre Sorhus
parent 119c41d39b
commit 3cbef48b6c
3 changed files with 28 additions and 0 deletions

View file

@ -150,4 +150,12 @@ const typedArrayTypes = new Set([
]);
is.typedArray = x => typedArrayTypes.has(getObjectType(x));
is.inRange = (x, range) => {
if (is.number(range)) {
return (x >= Math.min(0, range)) && (x <= Math.max(range, 0));
}
return (is.array(range)) && (x >= Math.min.apply(Math, range)) && (x <= Math.max.apply(Math, range));
};
module.exports = is;