Skip to main content
Module

x/lodash/_arrayLikeKeys.js

A modern JavaScript utility library delivering modularity, performance, & extras.
Extremely Popular
Go to Latest
File
define(['./_baseTimes', './isArguments', './isArray', './_isIndex'], function(baseTimes, isArguments, isArray, isIndex) {
/** Used for built-in method references. */ var objectProto = Object.prototype;
/** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty;
/** * Creates an array of the enumerable property names of the array-like `value`. * * @private * @param {*} value The value to query. * @param {boolean} inherited Specify returning inherited property names. * @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;
for (var key in value) { if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && (key == 'length' || isIndex(key, length)))) { result.push(key); } } return result; }
return arrayLikeKeys;});