UNPKG

tamda

Version:

Practical functional programming library for TypeScript

22 lines (21 loc) 860 B
import { ObjectMap } from '../object-map'; import { Mapper } from '../operators'; /** * Groups an `array` by the key extracted from each item by a `keyFn`. * @param array Array to group by key. * @param keyFn Function that extracts a key from each item. */ export declare function groupBy<T>(array: T[], keyFn: KeyFn<T>): ObjectMap<T[]>; /** * Returns a function that * groups an `array` by the key extracted from each item by a `keyFn`. * @param keyFn Function that extracts a key from each item. */ export declare function groupBy<T>(keyFn: KeyFn<T>): typeof deferred; /** * Groups an `array` by the key extracted from each item by a previously specified `keyFn`. * @param array Array to group by key. */ declare function deferred<T>(array: T[]): ObjectMap<T[]>; declare type KeyFn<T> = Mapper<T, number | string>; export {};