1 var getNative = require('../internal/getNative'),
2 isArrayLike = require('../internal/isArrayLike'),
3 isObject = require('../lang/isObject'),
4 shimKeys = require('../internal/shimKeys');
6 /* Native method references for those with the same name as other `lodash` methods. */
7 var nativeKeys = getNative(Object, 'keys');
10 * Creates an array of the own enumerable property names of `object`.
12 * **Note:** Non-object values are coerced to objects. See the
13 * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
19 * @param {Object} object The object to query.
20 * @returns {Array} Returns the array of property names.
28 * Foo.prototype.c = 3;
31 * // => ['a', 'b'] (iteration order is not guaranteed)
36 var keys = !nativeKeys ? shimKeys : function(object) {
37 var Ctor = object == null ? undefined : object.constructor;
38 if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
39 (typeof object != 'function' && isArrayLike(object))) {
40 return shimKeys(object);
42 return isObject(object) ? nativeKeys(object) : [];
45 module.exports = keys;