es7.object.get-own-property-descriptors.js 690 B

12345678910111213141516171819202122
  1. // https://github.com/tc39/proposal-object-getownpropertydescriptors
  2. var $export = require('./_export');
  3. var ownKeys = require('./_own-keys');
  4. var toIObject = require('./_to-iobject');
  5. var gOPD = require('./_object-gopd');
  6. var createProperty = require('./_create-property');
  7. $export($export.S, 'Object', {
  8. getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {
  9. var O = toIObject(object);
  10. var getDesc = gOPD.f;
  11. var keys = ownKeys(O);
  12. var result = {};
  13. var i = 0;
  14. var key, desc;
  15. while (keys.length > i) {
  16. desc = getDesc(O, key = keys[i++]);
  17. if (desc !== undefined) createProperty(result, key, desc);
  18. }
  19. return result;
  20. }
  21. });