import { IndexedSelector } from "../types/IndexedSelector"; import { MapFactory } from "../types/MapFactory"; /** * Materializes a sequence into a map keyed by the projected key selector. * * @typeParam T - Element type produced by the source iterable. * @typeParam TKey - Key type returned by `keySelector`. * @typeParam TValue - Value type stored in the resulting map when `valueSelector` is supplied. * @param src - Source iterable to materialize. * @param keySelector - Projection invoked with each element and index to produce the map key. * @param valueSelector - Optional projection producing the value that should be stored for the key; defaults to the element itself. * @param mapFactory - Optional factory controlling the concrete map implementation to instantiate. * @returns A map containing one entry per source element keyed by `keySelector`. * @throws {Error} If `keySelector` produces the same key more than once. * @example * ```ts * const byId = _toMap( * [ * { id: 1, name: "Ada" }, * { id: 2, name: "Linus" }, * ], * (person) => person.id, * (person) => person.name * ); * console.log(byId.get(2)); // "Linus" * ``` */ export declare function _toMap(src: Iterable, keySelector: IndexedSelector, mapFactory?: MapFactory): Map; export declare function _toMap(src: Iterable, keySelector: IndexedSelector, valueSelector: IndexedSelector, mapFactory?: MapFactory): Map; /** * Curried version of {@link _toMap}. */ export declare function toMap(keySelector: IndexedSelector, mapFactory?: MapFactory): (src: Iterable) => Map; export declare function toMap(keySelector: IndexedSelector, valueSelector: IndexedSelector, mapFactory?: MapFactory): (src: Iterable) => Map;