UNPKG

sequency

Version:

Functional sequences for processing iterable data in JavaScript

35 lines (34 loc) 1.26 kB
export declare class AssociateBy<T> { /** * Returns a map consisting of the elements mapped by the given `keySelector`. * * @param {(value: T) => K} keySelector * @returns {Map<K, T>} */ associateBy<K>(keySelector: (value: T) => K): Map<K, T>; /** * Returns a map consisting of the elements indexed by the given `key`. * * @param {K} key * @returns {Map<T[K], T>} */ associateBy<K extends keyof T>(key: K): Map<T[K], T>; /** * Returns a map consisting of the elements mapped by the given `keySelector`. The value * is transformed into another value by the `valueTransformer`. * * @param {(value: T) => K} keySelector * @param {(value: T) => V} valueTransformer * @returns {Map<K, V>} */ associateBy<K, V>(keySelector: (value: T) => K, valueTransformer: (value: T) => V): Map<K, V>; /** * Returns a map consisting of the elements indexed by the given `key`. The value * is transformed into another value by the `valueTransformer`. * * @param {K} key * @param {(value: T) => V} valueTransformer * @returns {Map<K, V>} */ associateBy<K extends keyof T, V>(key: K, valueTransformer: (value: T) => V): Map<T[K], V>; }