es.object.get-own-property-descriptors.js 1021 B

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