UNPKG

1.36 kBSource Map (JSON)View Raw
1{"version":3,"sources":["asynciterable/toarray.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,MAA8B,EAC9B,MAAoB;IAEpB,cAAc,CAAC,MAAM,CAAC,CAAC;IACvB,MAAM,OAAO,GAAG,EAAe,CAAC;IAChC,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;QACtD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACpB;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","file":"toarray.js","sourcesContent":["import { wrapWithAbort } from './operators/withabort';\nimport { throwIfAborted } from '../aborterror';\n\n/**\n * Converts an existing async-iterable to a promise containing the array of values.\n *\n * @export\n * @template TSource The type of elements in the source sequence.\n * @param {AsyncIterable<TSource>} source The source sequence to convert to an array.\n * @param {AbortSignal} [signal] An optional abort signal to cancel the operation at any time.\n * @returns {Promise<TSource[]>} A promise containing all the items from the source sequence as an array.\n */\nexport async function toArray<TSource>(\n source: AsyncIterable<TSource>,\n signal?: AbortSignal\n): Promise<TSource[]> {\n throwIfAborted(signal);\n const results = [] as TSource[];\n for await (const item of wrapWithAbort(source, signal)) {\n results.push(item);\n }\n return results;\n}\n"]}
\No newline at end of file