1 | import { AsyncIterableX } from './asynciterablex';
|
2 | export class TakeUntilAsyncIterable extends AsyncIterableX {
|
3 | constructor(source, other) {
|
4 | super();
|
5 | this._source = source;
|
6 | this._other = other;
|
7 | }
|
8 | async *[Symbol.asyncIterator]() {
|
9 | let otherDone = false;
|
10 | this._other().then(() => (otherDone = true));
|
11 | for await (let item of this._source) {
|
12 | if (otherDone) {
|
13 | break;
|
14 | }
|
15 | yield item;
|
16 | }
|
17 | }
|
18 | }
|
19 | export function takeUntil(source, other) {
|
20 | return new TakeUntilAsyncIterable(source, other);
|
21 | }
|
22 |
|
23 |
|