You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
631 B
37 lines
631 B
4 years ago
|
'use strict';
|
||
|
|
||
|
// MODULES //
|
||
|
|
||
|
var isInteger = require( 'validate.io-integer-primitive' );
|
||
|
|
||
|
|
||
|
// CONSTANTS //
|
||
|
|
||
|
var MAX = require( 'const-max-uint32' );
|
||
|
|
||
|
|
||
|
// IS ARRAY-LIKE //
|
||
|
|
||
|
/**
|
||
|
* FUNCTION: isArrayLike( value )
|
||
|
* Validates if a value is array-like.
|
||
|
*
|
||
|
* @param {*} value - value to validate
|
||
|
* @param {Boolean} boolean indicating if a value is array-like
|
||
|
*/
|
||
|
function isArrayLike( value ) {
|
||
|
return (
|
||
|
value !== void 0 &&
|
||
|
value !== null &&
|
||
|
typeof value !== 'function' &&
|
||
|
isInteger( value.length ) &&
|
||
|
value.length >= 0 &&
|
||
|
value.length <= MAX
|
||
|
);
|
||
|
} // end FUNCTION isArrayLike()
|
||
|
|
||
|
|
||
|
// EXPORTS //
|
||
|
|
||
|
module.exports = isArrayLike;
|