UNPKG

624 BJavaScriptView Raw
1import { AsyncIterableX } from '../asynciterable';
2import { bindCallback } from '../util/bindcallback';
3class MapAsyncIterable extends AsyncIterableX {
4 constructor(source, selector) {
5 super();
6 this._source = source;
7 this._selector = selector;
8 }
9 async *[Symbol.asyncIterator]() {
10 let i = 0;
11 for await (const item of this._source) {
12 yield await this._selector(item, i++);
13 }
14 }
15}
16export function mapAsync(source, selector, thisArg) {
17 return new MapAsyncIterable(source, bindCallback(selector, thisArg, 2));
18}
19
20//# sourceMappingURL=mapasync.mjs.map