mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 18:37:50 +00:00
Normalize keys of buffers and typed arrays.
This commit is contained in:
21
lodash.js
21
lodash.js
@@ -2387,17 +2387,22 @@
|
|||||||
* @returns {Array} Returns the array of property names.
|
* @returns {Array} Returns the array of property names.
|
||||||
*/
|
*/
|
||||||
function arrayLikeKeys(value, inherited) {
|
function arrayLikeKeys(value, inherited) {
|
||||||
// Safari 9 makes `arguments.length` enumerable in strict mode.
|
var isArr = isArray(value),
|
||||||
var result = (isArray(value) || isArguments(value))
|
isArg = !isArr && isArguments(value),
|
||||||
? baseTimes(value.length, String)
|
isBuff = !isArr && !isArg && isBuffer(value),
|
||||||
: [];
|
isType = !isArr && !isArg && !isBuff && isTypedArray(value),
|
||||||
|
skipIndexes = isArr || isArg || isBuff || isType,
|
||||||
var length = result.length,
|
result = skipIndexes ? baseTimes(value.length, String) : [],
|
||||||
skipIndexes = !!length;
|
length = result.length;
|
||||||
|
|
||||||
for (var key in value) {
|
for (var key in value) {
|
||||||
if ((inherited || hasOwnProperty.call(value, key)) &&
|
if ((inherited || hasOwnProperty.call(value, key)) &&
|
||||||
!(skipIndexes && (key == 'length' || isIndex(key, length)))) {
|
!(skipIndexes && (
|
||||||
|
key == 'length' ||
|
||||||
|
(isBuff && (key == 'offset' || key == 'parent')) ||
|
||||||
|
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
|
||||||
|
isIndex(key, length)
|
||||||
|
))) {
|
||||||
result.push(key);
|
result.push(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user