es6.reflect.enumerate.js 749 B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. // 26.1.5 Reflect.enumerate(target)
  3. var $export = require('./_export');
  4. var anObject = require('./_an-object');
  5. var Enumerate = function (iterated) {
  6. this._t = anObject(iterated); // target
  7. this._i = 0; // next index
  8. var keys = this._k = []; // keys
  9. var key;
  10. for (key in iterated) keys.push(key);
  11. };
  12. require('./_iter-create')(Enumerate, 'Object', function () {
  13. var that = this;
  14. var keys = that._k;
  15. var key;
  16. do {
  17. if (that._i >= keys.length) return { value: undefined, done: true };
  18. } while (!((key = keys[that._i++]) in that._t));
  19. return { value: key, done: false };
  20. });
  21. $export($export.S, 'Reflect', {
  22. enumerate: function enumerate(target) {
  23. return new Enumerate(target);
  24. }
  25. });