1 | import arrayLikeKeys from './_arrayLikeKeys.js';
|
2 | import baseKeys from './_baseKeys.js';
|
3 | import isArrayLike from './isArrayLike.js';
|
4 |
|
5 | /**
|
6 | * Creates an array of the own enumerable property names of `object`.
|
7 | *
|
8 | * **Note:** Non-object values are coerced to objects. See the
|
9 | * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
|
10 | * for more details.
|
11 | *
|
12 | * @static
|
13 | * @since 0.1.0
|
14 | * @memberOf _
|
15 | * @category Object
|
16 | * @param {Object} object The object to query.
|
17 | * @returns {Array} Returns the array of property names.
|
18 | * @example
|
19 | *
|
20 | * function Foo() {
|
21 | * this.a = 1;
|
22 | * this.b = 2;
|
23 | * }
|
24 | *
|
25 | * Foo.prototype.c = 3;
|
26 | *
|
27 | * _.keys(new Foo);
|
28 | * // => ['a', 'b'] (iteration order is not guaranteed)
|
29 | *
|
30 | * _.keys('hi');
|
31 | * // => ['0', '1']
|
32 | */
|
33 | function keys(object) {
|
34 | return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
|
35 | }
|
36 |
|
37 | export default keys;
|