summaryrefslogtreecommitdiff
path: root/tools/eslint/node_modules/lodash/_arrayLikeKeys.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/eslint/node_modules/lodash/_arrayLikeKeys.js')
-rw-r--r--tools/eslint/node_modules/lodash/_arrayLikeKeys.js30
1 files changed, 20 insertions, 10 deletions
diff --git a/tools/eslint/node_modules/lodash/_arrayLikeKeys.js b/tools/eslint/node_modules/lodash/_arrayLikeKeys.js
index 0cb3b18556..b2ec9ce786 100644
--- a/tools/eslint/node_modules/lodash/_arrayLikeKeys.js
+++ b/tools/eslint/node_modules/lodash/_arrayLikeKeys.js
@@ -1,7 +1,9 @@
var baseTimes = require('./_baseTimes'),
isArguments = require('./isArguments'),
isArray = require('./isArray'),
- isIndex = require('./_isIndex');
+ isBuffer = require('./isBuffer'),
+ isIndex = require('./_isIndex'),
+ isTypedArray = require('./isTypedArray');
/** Used for built-in method references. */
var objectProto = Object.prototype;
@@ -18,18 +20,26 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* @returns {Array} Returns the array of property names.
*/
function arrayLikeKeys(value, inherited) {
- // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
- // Safari 9 makes `arguments.length` enumerable in strict mode.
- var result = (isArray(value) || isArguments(value))
- ? baseTimes(value.length, String)
- : [];
-
- var length = result.length,
- skipIndexes = !!length;
+ var isArr = isArray(value),
+ isArg = !isArr && isArguments(value),
+ isBuff = !isArr && !isArg && isBuffer(value),
+ isType = !isArr && !isArg && !isBuff && isTypedArray(value),
+ skipIndexes = isArr || isArg || isBuff || isType,
+ result = skipIndexes ? baseTimes(value.length, String) : [],
+ length = result.length;
for (var key in value) {
if ((inherited || hasOwnProperty.call(value, key)) &&
- !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
+ !(skipIndexes && (
+ // Safari 9 has enumerable `arguments.length` in strict mode.
+ key == 'length' ||
+ // Node.js 0.10 has enumerable non-index properties on buffers.
+ (isBuff && (key == 'offset' || key == 'parent')) ||
+ // PhantomJS 2 has enumerable non-index properties on typed arrays.
+ (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
+ // Skip index properties.
+ isIndex(key, length)
+ ))) {
result.push(key);
}
}