source: trip-planner-front/node_modules/core-js/modules/esnext.async-iterator.as-indexed-pairs.js@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 849 bytes
Line 
1'use strict';
2// https://github.com/tc39/proposal-iterator-helpers
3var $ = require('../internals/export');
4var anObject = require('../internals/an-object');
5var createAsyncIteratorProxy = require('../internals/async-iterator-create-proxy');
6
7var AsyncIteratorProxy = createAsyncIteratorProxy(function (arg, Promise) {
8 var state = this;
9 var iterator = state.iterator;
10
11 return Promise.resolve(anObject(state.next.call(iterator, arg))).then(function (step) {
12 if (anObject(step).done) {
13 state.done = true;
14 return { done: true, value: undefined };
15 }
16 return { done: false, value: [state.index++, step.value] };
17 });
18});
19
20$({ target: 'AsyncIterator', proto: true, real: true }, {
21 asIndexedPairs: function asIndexedPairs() {
22 return new AsyncIteratorProxy({
23 iterator: anObject(this),
24 index: 0
25 });
26 }
27});
Note: See TracBrowser for help on using the repository browser.