2 // https://github.com/tc39/proposal-iterator-helpers
3 var $ = require('../internals/export');
4 var apply = require('../internals/function-apply');
5 var call = require('../internals/function-call');
6 var anObject = require('../internals/an-object');
7 var toPositiveInteger = require('../internals/to-positive-integer');
8 var createIteratorProxy = require('../internals/iterator-create-proxy');
10 var IteratorProxy = createIteratorProxy(function (args) {
11 var iterator = this.iterator;
14 while (this.remaining) {
16 result = anObject(call(next, iterator));
17 done = this.done = !!result.done;
20 result = anObject(apply(next, iterator, args));
21 done = this.done = !!result.done;
22 if (!done) return result.value;
25 $({ target: 'Iterator', proto: true, real: true }, {
26 drop: function drop(limit) {
27 return new IteratorProxy({
28 iterator: anObject(this),
29 remaining: toPositiveInteger(limit)