UNPKG

1.35 kBSource Map (JSON)View Raw
1{"version":3,"sources":["asynciterable/toset.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,KAAK,CACzB,MAA8B,EAC9B,MAAoB;IAEpB,cAAc,CAAC,MAAM,CAAC,CAAC;IACvB,MAAM,GAAG,GAAG,IAAI,GAAG,EAAW,CAAC;IAC/B,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;QACtD,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;KACf;IACD,OAAO,GAAG,CAAC;AACb,CAAC","file":"toset.js","sourcesContent":["import { wrapWithAbort } from './operators/withabort';\nimport { throwIfAborted } from '../aborterror';\n\n/**\n * Converts the existing async-iterable into a promise which resolves a Set.\n *\n * @export\n * @template TSource The type of elements in the source sequence.\n * @param {AsyncIterable<TSource>} source The async-iterable to convert into a set.\n * @param {AbortSignal} [signal] An optional abort signal to cancel the operation at any time.\n * @returns {Promise<Set<TSource>>} A promise which contains a Set with all the elements from the async-iterable.\n */\nexport async function toSet<TSource>(\n source: AsyncIterable<TSource>,\n signal?: AbortSignal\n): Promise<Set<TSource>> {\n throwIfAborted(signal);\n const set = new Set<TSource>();\n for await (const item of wrapWithAbort(source, signal)) {\n set.add(item);\n }\n return set;\n}\n"]}
\No newline at end of file