UNPKG

556 BJavaScriptView Raw
1import { AsyncIterableX } from './asynciterablex';
2class WhileAsyncIterable extends AsyncIterableX {
3 constructor(condition, source) {
4 super();
5 this._condition = condition;
6 this._source = source;
7 }
8 async *[Symbol.asyncIterator]() {
9 while (await this._condition()) {
10 for await (let item of this._source) {
11 yield item;
12 }
13 }
14 }
15}
16export function _while(condition, source) {
17 return new WhileAsyncIterable(condition, source);
18}
19
20//# sourceMappingURL=while.mjs.map