Add is.withinRange
This commit is contained in:
parent
103c5afe6f
commit
e209990682
2 changed files with 9 additions and 0 deletions
2
index.js
2
index.js
|
|
@ -148,4 +148,6 @@ const typedArrayTypes = new Set([
|
|||
]);
|
||||
is.typedArray = x => typedArrayTypes.has(getObjectType(x));
|
||||
|
||||
is.withinRange = (x, arr) => (x > Math.min.apply(Math, arr)) && (x < Math.max.apply(Math, arr));
|
||||
|
||||
module.exports = is;
|
||||
|
|
|
|||
7
test.js
7
test.js
|
|
@ -293,3 +293,10 @@ test('is.typedArray', t => {
|
|||
t.false(m.typedArray([]));
|
||||
t.false(m.typedArray({}));
|
||||
});
|
||||
|
||||
test('is.withinRange', t => {
|
||||
const x = 3;
|
||||
const arr = [0, 5];
|
||||
|
||||
t.true(m.withinRange(x, arr));
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue