UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

39 lines (38 loc) 1.15 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.isArrayLike = void 0; const isFunction_1 = __importDefault(require("./isFunction")); const isLength_1 = __importDefault(require("./isLength")); /** * Checks if `value` is array-like. A value is considered array-like if it's * not a function and has a `value.length` that's an integer greater than or * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. * * @since 5.3.0 * @category Lang * @param value The value to check. * @returns Returns `true` if `value` is array-like, else `false`. * @example * * ```js * isArrayLike([1, 2, 3]) * // => true * * isArrayLike(document.body.children) * // => true * * isArrayLike('abc') * // => true * * isArrayLike(Function) * // => false * ``` */ function isArrayLike(value) { return value != null && (0, isLength_1.default)(value.length) && !(0, isFunction_1.default)(value); } exports.isArrayLike = isArrayLike; exports.default = isArrayLike;