Urara-Blog/node_modules/.pnpm-store/v3/files/4f/54d0e6d83181f307ed4a0b1aee517ef3d98a13d4ab05a131dbdacc1d574c95b725c20db94af43ad11290fdfddaf4a52ca61341d35371899d53af643002c9de
2022-08-14 01:14:53 +08:00

25 lines
759 B
Text

/** Used as references for various `Number` constants. */
var MAX_SAFE_INTEGER = 9007199254740991;
/** Used to detect unsigned integer values. */
var reIsUint = /^(?:0|[1-9]\d*)$/;
/**
* Checks if `value` is a valid array-like index.
*
* @private
* @param {*} value The value to check.
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
*/
function isIndex(value, length) {
var type = typeof value;
length = length == null ? MAX_SAFE_INTEGER : length;
return !!length &&
(type == 'number' ||
(type != 'symbol' && reIsUint.test(value))) &&
(value > -1 && value % 1 == 0 && value < length);
}
module.exports = isIndex;