import { AsyncIterableX } from './asynciterablex.js'; import { wrapWithAbort } from './operators/withabort.js'; import { throwIfAborted } from '../aborterror.js'; /** @ignore */ export class OnErrorResumeNextAsyncIterable extends AsyncIterableX { private _source: Iterable>; constructor(source: Iterable>) { super(); this._source = source; } async *[Symbol.asyncIterator](signal?: AbortSignal) { throwIfAborted(signal); for (const item of this._source) { const it = wrapWithAbort(item, signal)[Symbol.asyncIterator](); while (1) { let next; try { next = await it.next(); } catch (e) { break; } if (next.done) { break; } yield next.value; } } } } /** * Concatenates all of the specified async-iterable sequences, even if the previous async-iterable sequence terminated exceptionally. * * @template T The type of the elements in the source sequences. * @param {...AsyncIterable[]} args Async-iterable sequences to concatenate. * @returns {AsyncIterableX} An async-iterable sequence that concatenates the source sequences, even if a sequence terminates exceptionally. */ export function onErrorResumeNext(...args: AsyncIterable[]): AsyncIterableX { return new OnErrorResumeNextAsyncIterable(args); }