From d14a0ce59239b64136b47b8e027d2b31a1c3abf3 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 22 Dec 2014 11:45:39 -0600 Subject: [PATCH] Use `isLength` in `_.keys`, `_.keysIn`, and `shimKeys`. --- lodash.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lodash.js b/lodash.js index 3b13c72d0..d66a52ca9 100644 --- a/lodash.js +++ b/lodash.js @@ -3807,7 +3807,7 @@ length = propsLength && object.length, support = lodash.support; - var allowIndexes = typeof length == 'number' && length > 0 && + var allowIndexes = length && isLength(length) && (isArray(object) || (support.nonEnumStrings && isString(object)) || (support.nonEnumArgs && isArguments(object))); @@ -8530,8 +8530,7 @@ length = object.length; } if ((typeof Ctor == 'function' && Ctor.prototype === object) || - (typeof length == 'number' && length > 0) || - (lodash.support.enumPrototypes && typeof object == 'function')) { + (typeof object == 'function' ? lodash.support.enumPrototypes : (length && isLength(length)))) { return shimKeys(object); } return isObject(object) ? nativeKeys(object) : []; @@ -8567,7 +8566,7 @@ var length = object.length, support = lodash.support; - length = (typeof length == 'number' && length > 0 && + length = (length && isLength(length) && (isArray(object) || (support.nonEnumStrings && isString(object)) || (support.nonEnumArgs && isArguments(object))) && length) || 0;