2140
2141
[Symbol.asyncIterator](): AsyncIterator<T, undefined, undefined> {
2143
>
return {
2144
>
next: async () => {
2145
>
do {
2146
>
if (this._state === AsyncIterableSourceState.DoneError) {
2147
throw this._error;
2148
}
2149
>
if (i < this._results.length) {
async.ts
2150
return { done: false, value: this._results[i++] };
2151
}
2152
>
if (this._state === AsyncIterableSourceState.DoneOK) {
async.ts
2153
return { done: true, value: undefined };
2154
}
2155
>
await Event.toPromise(this._onStateChanged.event);
async.ts
2156
>
} while (true);
2157
>
},
2158
>
return: async () => {
2159
this._onReturn?.();
2160
return { done: true, value: undefined };
2161
}
2163
>
}
2164
2165
public static map<T, R>(iterable: AsyncIterable<T>, mapFn: (item: T) => R): AsyncIterableObject<R> {