Add default 0 as lower bound if range is a number. Update tests
This commit is contained in:
parent
be967d4d01
commit
b30101d07e
3 changed files with 17 additions and 3 deletions
8
index.js
8
index.js
|
|
@ -148,6 +148,12 @@ const typedArrayTypes = new Set([
|
|||
]);
|
||||
is.typedArray = x => typedArrayTypes.has(getObjectType(x));
|
||||
|
||||
is.inRange = (x, arr) => is.array(arr) && (x >= Math.min.apply(Math, arr)) && (x <= Math.max.apply(Math, arr));
|
||||
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