Last change
on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
972 bytes
|
Line | |
---|
1 | var DESCRIPTORS = require('../internals/descriptors');
|
---|
2 | var objectKeys = require('../internals/object-keys');
|
---|
3 | var toIndexedObject = require('../internals/to-indexed-object');
|
---|
4 | var propertyIsEnumerable = require('../internals/object-property-is-enumerable').f;
|
---|
5 |
|
---|
6 | // `Object.{ entries, values }` methods implementation
|
---|
7 | var createMethod = function (TO_ENTRIES) {
|
---|
8 | return function (it) {
|
---|
9 | var O = toIndexedObject(it);
|
---|
10 | var keys = objectKeys(O);
|
---|
11 | var length = keys.length;
|
---|
12 | var i = 0;
|
---|
13 | var result = [];
|
---|
14 | var key;
|
---|
15 | while (length > i) {
|
---|
16 | key = keys[i++];
|
---|
17 | if (!DESCRIPTORS || propertyIsEnumerable.call(O, key)) {
|
---|
18 | result.push(TO_ENTRIES ? [key, O[key]] : O[key]);
|
---|
19 | }
|
---|
20 | }
|
---|
21 | return result;
|
---|
22 | };
|
---|
23 | };
|
---|
24 |
|
---|
25 | module.exports = {
|
---|
26 | // `Object.entries` method
|
---|
27 | // https://tc39.es/ecma262/#sec-object.entries
|
---|
28 | entries: createMethod(true),
|
---|
29 | // `Object.values` method
|
---|
30 | // https://tc39.es/ecma262/#sec-object.values
|
---|
31 | values: createMethod(false)
|
---|
32 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.