Rename to inRange and reuse the Math module
This commit is contained in:
parent
ea63fb743a
commit
20bc7331ad
2 changed files with 3 additions and 3 deletions
2
index.js
2
index.js
|
|
@ -148,6 +148,6 @@ const typedArrayTypes = new Set([
|
|||
]);
|
||||
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;
|
||||
|
|
|
|||
4
test.js
4
test.js
|
|
@ -294,9 +294,9 @@ test('is.typedArray', t => {
|
|||
t.false(m.typedArray({}));
|
||||
});
|
||||
|
||||
test('is.withinRange', t => {
|
||||
test('is.inRange', t => {
|
||||
const x = 3;
|
||||
const arr = [0, 5];
|
||||
|
||||
t.true(m.withinRange(x, arr));
|
||||
t.true(m.inRange(x, arr));
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue