Security update for permissions_by_term
[yaffs-website] / node_modules / uncss / node_modules / lodash / keys.js
1 var baseHas = require('./internal/baseHas'),
2     baseKeys = require('./internal/baseKeys'),
3     indexKeys = require('./internal/indexKeys'),
4     isArrayLike = require('./isArrayLike'),
5     isIndex = require('./internal/isIndex'),
6     isPrototype = require('./internal/isPrototype');
7
8 /**
9  * Creates an array of the own enumerable property names of `object`.
10  *
11  * **Note:** Non-object values are coerced to objects. See the
12  * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
13  * for more details.
14  *
15  * @static
16  * @memberOf _
17  * @category Object
18  * @param {Object} object The object to query.
19  * @returns {Array} Returns the array of property names.
20  * @example
21  *
22  * function Foo() {
23  *   this.a = 1;
24  *   this.b = 2;
25  * }
26  *
27  * Foo.prototype.c = 3;
28  *
29  * _.keys(new Foo);
30  * // => ['a', 'b'] (iteration order is not guaranteed)
31  *
32  * _.keys('hi');
33  * // => ['0', '1']
34  */
35 function keys(object) {
36   var isProto = isPrototype(object);
37   if (!(isProto || isArrayLike(object))) {
38     return baseKeys(object);
39   }
40   var indexes = indexKeys(object),
41       skipIndexes = !!indexes,
42       result = indexes || [],
43       length = result.length;
44
45   for (var key in object) {
46     if (baseHas(object, key) &&
47         !(skipIndexes && (key == 'length' || isIndex(key, length))) &&
48         !(isProto && key == 'constructor')) {
49       result.push(key);
50     }
51   }
52   return result;
53 }
54
55 module.exports = keys;