Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
637 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | // https://github.com/tc39/proposal-iterator-helpers
|
---|
3 | var $ = require('../internals/export');
|
---|
4 | var anObject = require('../internals/an-object');
|
---|
5 | var createIteratorProxy = require('../internals/iterator-create-proxy');
|
---|
6 |
|
---|
7 | var IteratorProxy = createIteratorProxy(function (arg) {
|
---|
8 | var result = anObject(this.next.call(this.iterator, arg));
|
---|
9 | var done = this.done = !!result.done;
|
---|
10 | if (!done) return [this.index++, result.value];
|
---|
11 | });
|
---|
12 |
|
---|
13 | $({ target: 'Iterator', proto: true, real: true }, {
|
---|
14 | asIndexedPairs: function asIndexedPairs() {
|
---|
15 | return new IteratorProxy({
|
---|
16 | iterator: anObject(this),
|
---|
17 | index: 0
|
---|
18 | });
|
---|
19 | }
|
---|
20 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.