UNPKG

864 BJavaScriptView Raw
1import getLength from './_getLength';
2import isFunction from './isFunction';
3import isLength from './isLength';
4
5/**
6 * Checks if `value` is array-like. A value is considered array-like if it's
7 * not a function and has a `value.length` that's an integer greater than or
8 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
9 *
10 * @static
11 * @memberOf _
12 * @since 4.0.0
13 * @category Lang
14 * @param {*} value The value to check.
15 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
16 * @example
17 *
18 * _.isArrayLike([1, 2, 3]);
19 * // => true
20 *
21 * _.isArrayLike(document.body.children);
22 * // => true
23 *
24 * _.isArrayLike('abc');
25 * // => true
26 *
27 * _.isArrayLike(_.noop);
28 * // => false
29 */
30function isArrayLike(value) {
31 return value != null && isLength(getLength(value)) && !isFunction(value);
32}
33
34export default isArrayLike;