UNPKG

1.5 kBSource Map (JSON)View Raw
1{"version":3,"sources":["asynciterable/tomap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAWrD,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,MAA8B,EAC9B,WAAoD,EACpD,kBAAmE,aAAa;IAEhF,IAAI,GAAG,GAAG,IAAI,GAAG,EAA4B,CAAC;IAC9C,IAAI,KAAK,EAAE,IAAI,IAAI,IAAI,MAAM,EAAE;QAC7B,IAAI,KAAK,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,GAAG,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;QAClC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;KACrB;IACD,OAAO,GAAG,CAAC;AACb,CAAC","file":"tomap.js","sourcesContent":["import { identityAsync } from '../internal/identity';\n\nexport async function toMap<TSource, TKey>(\n source: AsyncIterable<TSource>,\n keySelector: (item: TSource) => TKey | Promise<TKey>\n): Promise<Map<TKey, TSource>>;\nexport async function toMap<TSource, TKey, TElement = TSource>(\n source: AsyncIterable<TSource>,\n keySelector: (item: TSource) => TKey | Promise<TKey>,\n elementSelector?: (item: TSource) => TElement | Promise<TElement>\n): Promise<Map<TKey, TElement>>;\nexport async function toMap<TSource, TKey, TElement = TSource>(\n source: AsyncIterable<TSource>,\n keySelector: (item: TSource) => TKey | Promise<TKey>,\n elementSelector: (item: TSource) => TElement | Promise<TElement> = identityAsync\n): Promise<Map<TKey, TElement | TSource>> {\n let map = new Map<TKey, TElement | TSource>();\n for await (let item of source) {\n let value = await elementSelector(item);\n let key = await keySelector(item);\n map.set(key, value);\n }\n return map;\n}\n"]}
\No newline at end of file