Add is.inRange() (#3)
This commit is contained in:
parent
119c41d39b
commit
3cbef48b6c
3 changed files with 28 additions and 0 deletions
8
index.js
8
index.js
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue