2016-10-10 03:43:44 +02:00
|
|
|
'use strict';
|
|
|
|
// 26.1.5 Reflect.enumerate(target)
|
2017-08-14 05:01:11 +02:00
|
|
|
var $export = require('./_export');
|
|
|
|
var anObject = require('./_an-object');
|
|
|
|
var Enumerate = function (iterated) {
|
2016-10-10 03:43:44 +02:00
|
|
|
this._t = anObject(iterated); // target
|
|
|
|
this._i = 0; // next index
|
2017-08-14 05:01:11 +02:00
|
|
|
var keys = this._k = []; // keys
|
|
|
|
var key;
|
|
|
|
for (key in iterated) keys.push(key);
|
2016-10-10 03:43:44 +02:00
|
|
|
};
|
2017-08-14 05:01:11 +02:00
|
|
|
require('./_iter-create')(Enumerate, 'Object', function () {
|
|
|
|
var that = this;
|
|
|
|
var keys = that._k;
|
|
|
|
var key;
|
2016-10-10 03:43:44 +02:00
|
|
|
do {
|
2017-08-14 05:01:11 +02:00
|
|
|
if (that._i >= keys.length) return { value: undefined, done: true };
|
|
|
|
} while (!((key = keys[that._i++]) in that._t));
|
|
|
|
return { value: key, done: false };
|
2016-10-10 03:43:44 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
$export($export.S, 'Reflect', {
|
2017-08-14 05:01:11 +02:00
|
|
|
enumerate: function enumerate(target) {
|
2016-10-10 03:43:44 +02:00
|
|
|
return new Enumerate(target);
|
|
|
|
}
|
2017-08-14 05:01:11 +02:00
|
|
|
});
|