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AAG,KAAK,CAAC;aACnB;YACD,MAAM,MAAM,CAAC;SACd;IACH,CAAC;CACF;AAgHD,MAAM,UAAU,GAAG,CAAI,GAAG,OAAc;IACtC,OAAO,IAAI,gBAAgB,CAAI,OAAO,CAAC,CAAC;AAC1C,CAAC","file":"zip.js","sourcesContent":["import { wrapWithAbort } from './operators/withabort';\nimport { AsyncIterableX } from './asynciterablex';\nimport { returnAsyncIterator } from '../util/returniterator';\nimport { throwIfAborted } from '../aborterror';\n\nexport class ZipAsyncIterable<TSource> extends AsyncIterableX<TSource[]> {\n private _sources: AsyncIterable<TSource>[];\n\n constructor(sources: AsyncIterable<TSource>[]) {\n super();\n this._sources = sources;\n }\n\n // eslint-disable-next-line consistent-return\n async *[Symbol.asyncIterator](signal?: AbortSignal): AsyncIterableIterator<TSource[]> {\n throwIfAborted(signal);\n const sourcesLength = this._sources.length;\n const its = this._sources.map((x) => wrapWithAbort(x, signal)[Symbol.asyncIterator]());\n while (sourcesLength > 0) {\n const values = new Array(sourcesLength);\n for (let i = -1; ++i < sourcesLength; ) {\n const { value, done } = await its[i].next();\n if (done) {\n await Promise.all(its.map(returnAsyncIterator));\n return undefined;\n }\n values[i] = value;\n }\n yield values;\n }\n }\n}\n\n/**\n * Merges multiple async-iterable sequences into one async-iterable sequence by combining their elements in a pairwise fashion.\n *\n * @export\n * @template T The type of the first async-iterable sequence.\n * @template T2 The type of the second async-iterable sequence.\n * @param {AsyncIterable<T>} source The first async-iterable source.\n * @param {AsyncIterable<T2>} source2 The second async-iterable source.\n * @returns {AsyncIterableX<[T, T2]>} Async iterable with an array of each element from the source sequences in a pairwise fashion.\n */\nexport function zip<T, T2>(\n source: AsyncIterable<T>,\n source2: AsyncIterable<T2>\n): AsyncIterableX<[T, T2]>;\n/**\n * Merges multiple async-iterable sequences into one async-iterable sequence by combining their elements in a pairwise fashion.\n *\n * @export\n * @template T The type of the first async-iterable sequence.\n * @template T2 The type of the second async-iterable sequence.\n * @template T3 The type of the third async-iterable sequence.\n * @param {AsyncIterable<T>} source The first async-iterable source.\n * @param {AsyncIterable<T2>} source2 The second async-iterable source.\n * @param {AsyncIterable<T3>} source3 The third async-iterable source.\n * @returns {AsyncIterableX<[T, T2, T3]>} Async iterable with an array of each element from the source sequences in a pairwise fashion.\n */\nexport function zip<T, T2, T3>(\n source: AsyncIterable<T>,\n source2: AsyncIterable<T2>,\n source3: AsyncIterable<T3>\n): AsyncIterableX<[T, T2, T3]>;\n/**\n * Merges multiple async-iterable sequences into one async-iterable sequence by combining their elements in a pairwise fashion.\n *\n * @export\n * @template T The type of the first async-iterable sequence.\n * @template T2 The type of the second async-iterable sequence.\n * @template T3 The type of the third async-iterable sequence.\n * @template T4 The type of the fourth async-iterable sequence.\n * @param {AsyncIterable<T>} source The first async-iterable source.\n * @param {AsyncIterable<T2>} source2 The second async-iterable source.\n * @param {AsyncIterable<T3>} source3 The third async-iterable source.\n * @param {AsyncIterable<T4>} source4 The fourth async-iterable source.\n * @returns {AsyncIterableX<[T, T2, T3, T4]>} Async iterable with an array of each element from the source sequences in a pairwise fashion.\n */\nexport function zip<T, T2, T3, T4>(\n source: AsyncIterable<T>,\n source2: AsyncIterable<T2>,\n source3: AsyncIterable<T3>,\n source4: AsyncIterable<T4>\n): AsyncIterableX<[T, T2, T3, T4]>;\n/**\n * Merges multiple async-iterable sequences into one async-iterable sequence by combining their elements in a pairwise fashion.\n *\n * @export\n * @template T The type of the first async-iterable sequence.\n * @template T2 The type of the second async-iterable sequence.\n * @template T3 The type of the third async-iterable sequence.\n * @template T4 The type of the fourth async-iterable sequence.\n * @template T5 The type of the fifth async-iterable sequence.\n * @param {AsyncIterable<T>} source The first async-iterable source.\n * @param {AsyncIterable<T2>} source2 The second async-iterable source.\n * @param {AsyncIterable<T3>} source3 The third async-iterable source.\n * @param {AsyncIterable<T4>} source4 The fourth async-iterable source.\n * @param {AsyncIterable<T5>} source5 The fifth async-iterable source.\n * @returns {AsyncIterableX<[T, T2, T3, T4, T5]>} Async iterable with an array of each element from the source sequences in a pairwise fashion.\n */\nexport function zip<T, T2, T3, T4, T5>(\n source: AsyncIterable<T>,\n source2: AsyncIterable<T2>,\n source3: AsyncIterable<T3>,\n source4: AsyncIterable<T4>,\n source5: AsyncIterable<T5>\n): AsyncIterableX<[T, T2, T3, T4, T5]>;\n/**\n * Merges multiple async-iterable sequences into one async-iterable sequence by combining their elements in a pairwise fashion.\n *\n * @export\n * @template T The type of the first async-iterable sequence.\n * @template T2 The type of the second async-iterable sequence.\n * @template T3 The type of the third async-iterable sequence.\n * @template T4 The type of the fourth async-iterable sequence.\n * @template T5 The type of the fifth async-iterable sequence.\n * @template T6 The type of the sixth async-iterable sequence.\n * @param {AsyncIterable<T>} source The first async-iterable source.\n * @param {AsyncIterable<T2>} source2 The second async-iterable source.\n * @param {AsyncIterable<T3>} source3 The third async-iterable source.\n * @param {AsyncIterable<T4>} source4 The fourth async-iterable source.\n * @param {AsyncIterable<T5>} source5 The fifth async-iterable source.\n * @param {AsyncIterable<T6>} source6 The sixth async-iterable source.\n * @returns {AsyncIterableX<[T, T2, T3, T4, T5, T6]>} Async iterable with an array of each element from the source sequences in a pairwise fashion.\n */\nexport function zip<T, T2, T3, T4, T5, T6>(\n source: AsyncIterable<T>,\n source2: AsyncIterable<T2>,\n source3: AsyncIterable<T3>,\n source4: AsyncIterable<T4>,\n source5: AsyncIterable<T5>,\n source6: AsyncIterable<T6>\n): AsyncIterableX<[T, T2, T3, T4, T5, T6]>;\n\n/**\n * Merges multiple async-iterable sequences into one async-iterable sequence by combining their elements in a pairwise fashion.\n *\n * @export\n * @template T The type of elements in the source sequences.\n * @param {...AsyncIterable<T>[]} sources The source sequences.\n * @returns {AsyncIterableX<T[]>} Async iterable with an array of each element from the source sequences in a pairwise fashion.\n */\nexport function zip<T>(...sources: AsyncIterable<T>[]): AsyncIterableX<T[]>;\nexport function zip<T>(...sources: any[]): AsyncIterableX<T[]> {\n return new ZipAsyncIterable<T>(sources);\n}\n"]}
\No newline at end of file