2 // https://github.com/tc39/proposal-iterator-helpers
3 var $ = require('../internals/export');
4 var anObject = require('../internals/an-object');
5 var toPositiveInteger = require('../internals/to-positive-integer');
6 var createIteratorProxy = require('../internals/iterator-create-proxy');
8 var IteratorProxy = createIteratorProxy(function (arg) {
9 var iterator = this.iterator;
12 while (this.remaining) {
14 result = anObject(next.call(iterator));
15 done = this.done = !!result.done;
18 result = anObject(next.call(iterator, arg));
19 done = this.done = !!result.done;
20 if (!done) return result.value;
23 $({ target: 'Iterator', proto: true, real: true }, {
24 drop: function drop(limit) {
25 return new IteratorProxy({
26 iterator: anObject(this),
27 remaining: toPositiveInteger(limit)