Rename to inRange and reuse the Math module

This commit is contained in:
glhrmv 2017-09-23 16:19:02 +01:00
parent ea63fb743a
commit 20bc7331ad
2 changed files with 3 additions and 3 deletions

View file

@ -148,6 +148,6 @@ const typedArrayTypes = new Set([
]); ]);
is.typedArray = x => typedArrayTypes.has(getObjectType(x)); is.typedArray = x => typedArrayTypes.has(getObjectType(x));
is.withinRange = (x, [min, max]) => x >= min && x <= max; is.inRange = (x, arr) => is.array(arr) && (x >= Math.min.apply(Math, arr)) && (x <= Math.max.apply(Math, arr));
module.exports = is; module.exports = is;

View file

@ -294,9 +294,9 @@ test('is.typedArray', t => {
t.false(m.typedArray({})); t.false(m.typedArray({}));
}); });
test('is.withinRange', t => { test('is.inRange', t => {
const x = 3; const x = 3;
const arr = [0, 5]; const arr = [0, 5];
t.true(m.withinRange(x, arr)); t.true(m.inRange(x, arr));
}); });