1 | /**
|
2 | * The options for the toMap method which include an optional element selector and abort signal for cancellation.
|
3 | *
|
4 | * @interface ToMapOptions
|
5 | * @template TSource
|
6 | * @template TElement
|
7 | */
|
8 | export interface ToMapOptions<TSource, TElement> {
|
9 | /**
|
10 | * The selector to get the key for the map.
|
11 | *
|
12 | * @memberof ToMapOptions
|
13 | */
|
14 | keySelector: (item: TSource) => TElement;
|
15 | /**
|
16 | * The selector used to get the element for the Map.
|
17 | *
|
18 | * @memberof ToMapOptions
|
19 | */
|
20 | elementSelector?: (item: TSource) => TElement;
|
21 | }
|
22 | /**
|
23 | * Converts an async-iterable to a map with a key selector and options for an element selector and cancellation.
|
24 | *
|
25 | * @export
|
26 | * @template TSource The type of elements in the source collection.
|
27 | * @template TKey The type of key used for the map.
|
28 | * @template TElement The type of element to use for the map.
|
29 | * @param {AsyncIterable<TSource>} source The source collection to turn into a map.
|
30 | * @param {ToMapOptions<TSource, TElement>} options The options for getting the key and element for the map.
|
31 | * @returns {(Map<TKey, TElement | TSource>)} A map containing the key and elements from the selector functions.
|
32 | */
|
33 | export declare function toMap<TSource, TKey, TElement = TSource>(source: Iterable<TSource>, options: ToMapOptions<TSource, TElement>): Map<TKey, TElement | TSource>;
|