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;oBAC9B,MAAM;iBACP;gBAED,MAAM,CAAC,CAAC;aACT;YAED,IAAI,CAAC,QAAQ,EAAE;gBACb,MAAM;aACP;SACF;QAED,IAAI,QAAQ,EAAE;YACZ,MAAM,KAAK,CAAC;SACb;IACH,CAAC;CACF;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CAAI,MAAkC;IAC5D,OAAO,IAAI,qBAAqB,CAAI,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAI,GAAG,IAAwB;IACvD,OAAO,IAAI,qBAAqB,CAAI,IAAI,CAAC,CAAC;AAC5C,CAAC","file":"catcherror.js","sourcesContent":["import { AsyncIterableX } from './asynciterablex';\nimport { returnAsyncIterator } from '../util/returniterator';\nimport { wrapWithAbort } from './operators/withabort';\nimport { throwIfAborted } from '../aborterror';\n\nexport class CatchAllAsyncIterable<TSource> extends AsyncIterableX<TSource> {\n private _source: Iterable<AsyncIterable<TSource>>;\n\n constructor(source: Iterable<AsyncIterable<TSource>>) {\n super();\n this._source = source;\n }\n\n async *[Symbol.asyncIterator](signal?: AbortSignal) {\n throwIfAborted(signal);\n\n let error = null;\n let hasError = false;\n\n for (const source of this._source) {\n const it = wrapWithAbort(source, signal)[Symbol.asyncIterator]();\n\n error = null;\n hasError = false;\n\n while (1) {\n let c = <TSource>{};\n\n try {\n const { done, value } = await it.next();\n if (done) {\n await returnAsyncIterator(it);\n break;\n }\n c = value;\n } catch (e) {\n error = e;\n hasError = true;\n await returnAsyncIterator(it);\n break;\n }\n\n yield c;\n }\n\n if (!hasError) {\n break;\n }\n }\n\n if (hasError) {\n throw error;\n }\n }\n}\n\n/**\n * Continues an async-iterable sequence that is terminated by an exception with the next async-iterable sequence.\n *\n * @export\n * @template T The type of the elements in the source and handler sequences.\n * @param {Iterable<AsyncIterable<T>>} source async-iterable sequences to catch exceptions for.\n * @returns {AsyncIterableX<T>} An async-iterable sequence containing elements from consecutive source\n * sequences until a source sequence terminates successfully.\n */\nexport function catchAll<T>(source: Iterable<AsyncIterable<T>>): AsyncIterableX<T> {\n return new CatchAllAsyncIterable<T>(source);\n}\n\n/**\n * Continues an async-iterable sequence that is terminated by an exception with the next async-iterable sequence.\n *\n * @export\n * @template T The type of the elements in the source and handler sequences.\n * @param {...AsyncIterable<T>[]} args async-iterable sequences to catch exceptions for.\n * @returns {AsyncIterableX<T>} An async-iterable sequence containing elements from consecutive source\n * sequences until a source sequence terminates successfully.\n */\nexport function catchError<T>(...args: AsyncIterable<T>[]): AsyncIterableX<T> {\n return new CatchAllAsyncIterable<T>(args);\n}\n"]}
\No newline at end of file