MCPcopy
hub / github.com/lodash/lodash / arrayLikeKeys

Function arrayLikeKeys

lodash.js:2430–2455  ·  view source on GitHub ↗

* Creates an array of the enumerable property names of the array-like `value`. * * @private * @param {*} value The value to query. * @param {boolean} inherited Specify returning inherited property names. * @returns {Array} Returns the array of property names.

(value, inherited)

Source from the content-addressed store, hash-verified

2428 * @returns {Array} Returns the array of property names.
2429 */
2430 function arrayLikeKeys(value, inherited) {
2431 var isArr = isArray(value),
2432 isArg = !isArr && isArguments(value),
2433 isBuff = !isArr && !isArg && isBuffer(value),
2434 isType = !isArr && !isArg && !isBuff && isTypedArray(value),
2435 skipIndexes = isArr || isArg || isBuff || isType,
2436 result = skipIndexes ? baseTimes(value.length, String) : [],
2437 length = result.length;
2438
2439 for (var key in value) {
2440 if ((inherited || hasOwnProperty.call(value, key)) &&
2441 !(skipIndexes && (
2442 // Safari 9 has enumerable `arguments.length` in strict mode.
2443 key == 'length' ||
2444 // Node.js 0.10 has enumerable non-index properties on buffers.
2445 (isBuff && (key == 'offset' || key == 'parent')) ||
2446 // PhantomJS 2 has enumerable non-index properties on typed arrays.
2447 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
2448 // Skip index properties.
2449 isIndex(key, length)
2450 ))) {
2451 result.push(key);
2452 }
2453 }
2454 return result;
2455 }
2456
2457 /**
2458 * A specialized version of `_.sample` for arrays.

Callers 2

keysFunction · 0.85
keysInFunction · 0.85

Calls 2

baseTimesFunction · 0.85
isIndexFunction · 0.85

Tested by

no test coverage detected