es.object.get-own-property-descriptors.js 1.0 KB

12345678910111213141516171819202122232425
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var DESCRIPTORS = require('../internals/descriptors');
  4. var ownKeys = require('../internals/own-keys');
  5. var toIndexedObject = require('../internals/to-indexed-object');
  6. var getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');
  7. var createProperty = require('../internals/create-property');
  8. // `Object.getOwnPropertyDescriptors` method
  9. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
  10. $({ target: 'Object', stat: true, sham: !DESCRIPTORS }, {
  11. getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {
  12. var O = toIndexedObject(object);
  13. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  14. var keys = ownKeys(O);
  15. var result = {};
  16. var index = 0;
  17. var key, descriptor;
  18. while (keys.length > index) {
  19. descriptor = getOwnPropertyDescriptor(O, key = keys[index++]);
  20. if (descriptor !== undefined) createProperty(result, key, descriptor);
  21. }
  22. return result;
  23. }
  24. });