mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 20:07:49 +00:00
Simplify _.keys and _.keysIn.
This commit is contained in:
committed by
John-David Dalton
parent
6dfc2aca4b
commit
0f12d43a59
@@ -3237,12 +3237,11 @@
|
|||||||
|
|
||||||
var keyIndex,
|
var keyIndex,
|
||||||
index = -1,
|
index = -1,
|
||||||
maxIndex = objLength - 1,
|
|
||||||
result = [];
|
result = [];
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var key = props[index];
|
var key = props[index];
|
||||||
if ((allowIndexes && (keyIndex = +key, keyIndex > -1 && keyIndex <= maxIndex && keyIndex % 1 == 0)) ||
|
if ((allowIndexes && (keyIndex = +key, keyIndex > -1 && keyIndex < objLength && keyIndex % 1 == 0)) ||
|
||||||
hasOwnProperty.call(object, key)) {
|
hasOwnProperty.call(object, key)) {
|
||||||
result.push(key);
|
result.push(key);
|
||||||
}
|
}
|
||||||
@@ -8019,7 +8018,6 @@
|
|||||||
Ctor = object.constructor,
|
Ctor = object.constructor,
|
||||||
index = -1,
|
index = -1,
|
||||||
isProto = typeof Ctor == 'function' && Ctor.prototype === object,
|
isProto = typeof Ctor == 'function' && Ctor.prototype === object,
|
||||||
maxIndex = length - 1,
|
|
||||||
result = Array(length),
|
result = Array(length),
|
||||||
skipIndexes = length > 0,
|
skipIndexes = length > 0,
|
||||||
skipErrorProps = support.enumErrorProps && (object === errorProto || object instanceof Error),
|
skipErrorProps = support.enumErrorProps && (object === errorProto || object instanceof Error),
|
||||||
@@ -8036,7 +8034,7 @@
|
|||||||
if (!(isProto && key == 'constructor') &&
|
if (!(isProto && key == 'constructor') &&
|
||||||
!(skipProto && key == 'prototype') &&
|
!(skipProto && key == 'prototype') &&
|
||||||
!(skipErrorProps && (key == 'message' || key == 'name')) &&
|
!(skipErrorProps && (key == 'message' || key == 'name')) &&
|
||||||
!(skipIndexes && (keyIndex = +key, keyIndex > -1 && keyIndex <= maxIndex && keyIndex % 1 == 0))) {
|
!(skipIndexes && (keyIndex = +key, keyIndex > -1 && keyIndex < length && keyIndex % 1 == 0))) {
|
||||||
result.push(key);
|
result.push(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user