Add is.arrayLike() (#26)

This commit is contained in:
Brandon Smith 2017-10-26 09:30:17 -04:00 committed by GitHub
parent 0bafa04e77
commit 83adc096ef
3 changed files with 29 additions and 0 deletions

View file

@ -155,6 +155,9 @@ const typedArrayTypes = new Set([
]);
is.typedArray = x => typedArrayTypes.has(getObjectType(x));
const isValidLength = x => is.safeInteger(x) && x > -1;
is.arrayLike = x => !is.nullOrUndefined(x) && !is.function(x) && isValidLength(x.length);
is.inRange = (x, range) => {
if (is.number(range)) {
return x >= Math.min(0, range) && x <= Math.max(range, 0);