mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 16:47: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,
|
||||
index = -1,
|
||||
maxIndex = objLength - 1,
|
||||
result = [];
|
||||
|
||||
while (++index < length) {
|
||||
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)) {
|
||||
result.push(key);
|
||||
}
|
||||
@@ -8019,7 +8018,6 @@
|
||||
Ctor = object.constructor,
|
||||
index = -1,
|
||||
isProto = typeof Ctor == 'function' && Ctor.prototype === object,
|
||||
maxIndex = length - 1,
|
||||
result = Array(length),
|
||||
skipIndexes = length > 0,
|
||||
skipErrorProps = support.enumErrorProps && (object === errorProto || object instanceof Error),
|
||||
@@ -8036,7 +8034,7 @@
|
||||
if (!(isProto && key == 'constructor') &&
|
||||
!(skipProto && key == 'prototype') &&
|
||||
!(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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user