"This is your life. Do what you love, and do it often." —@Holstee
const MAX_SAFE_INTEGER = 9007199254740991;
/** 用于检测无符号整数值 */
const reIsUint = /^(?:0|[1-9]\d*)$/;
/**
* 检查 `value` 是否是一个有效的类数组索引。
*
* @private
* @param {*} value 要检查的值。
* @param {number} [length=MAX_SAFE_INTEGER] 有效索引的上限。
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
*/
function isIndex(value, length) {
const 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);
}