[79a0317] | 1 | 'use strict';
|
---|
| 2 | var DESCRIPTORS = require('../internals/descriptors');
|
---|
| 3 | var fails = require('../internals/fails');
|
---|
| 4 | var uncurryThis = require('../internals/function-uncurry-this');
|
---|
| 5 | var objectGetPrototypeOf = require('../internals/object-get-prototype-of');
|
---|
| 6 | var objectKeys = require('../internals/object-keys');
|
---|
| 7 | var toIndexedObject = require('../internals/to-indexed-object');
|
---|
| 8 | var $propertyIsEnumerable = require('../internals/object-property-is-enumerable').f;
|
---|
| 9 |
|
---|
| 10 | var propertyIsEnumerable = uncurryThis($propertyIsEnumerable);
|
---|
| 11 | var push = uncurryThis([].push);
|
---|
| 12 |
|
---|
| 13 | // in some IE versions, `propertyIsEnumerable` returns incorrect result on integer keys
|
---|
| 14 | // of `null` prototype objects
|
---|
| 15 | var IE_BUG = DESCRIPTORS && fails(function () {
|
---|
| 16 | // eslint-disable-next-line es/no-object-create -- safe
|
---|
| 17 | var O = Object.create(null);
|
---|
| 18 | O[2] = 2;
|
---|
| 19 | return !propertyIsEnumerable(O, 2);
|
---|
| 20 | });
|
---|
| 21 |
|
---|
| 22 | // `Object.{ entries, values }` methods implementation
|
---|
| 23 | var createMethod = function (TO_ENTRIES) {
|
---|
| 24 | return function (it) {
|
---|
| 25 | var O = toIndexedObject(it);
|
---|
| 26 | var keys = objectKeys(O);
|
---|
| 27 | var IE_WORKAROUND = IE_BUG && objectGetPrototypeOf(O) === null;
|
---|
| 28 | var length = keys.length;
|
---|
| 29 | var i = 0;
|
---|
| 30 | var result = [];
|
---|
| 31 | var key;
|
---|
| 32 | while (length > i) {
|
---|
| 33 | key = keys[i++];
|
---|
| 34 | if (!DESCRIPTORS || (IE_WORKAROUND ? key in O : propertyIsEnumerable(O, key))) {
|
---|
| 35 | push(result, TO_ENTRIES ? [key, O[key]] : O[key]);
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
| 38 | return result;
|
---|
| 39 | };
|
---|
| 40 | };
|
---|
| 41 |
|
---|
| 42 | module.exports = {
|
---|
| 43 | // `Object.entries` method
|
---|
| 44 | // https://tc39.es/ecma262/#sec-object.entries
|
---|
| 45 | entries: createMethod(true),
|
---|
| 46 | // `Object.values` method
|
---|
| 47 | // https://tc39.es/ecma262/#sec-object.values
|
---|
| 48 | values: createMethod(false)
|
---|
| 49 | };
|
---|