UNPKG

tamda

Version:

Practical functional programming library for TypeScript

20 lines (19 loc) 884 B
import { Mapper } from '../operators'; /** * Creates partitions of an `array` by the key extracted from each item by a function `keyFn`. * @param array Array to partition. * @param keyFn Function that extracts a key from each item. Default: `identity`. */ export declare function partition<T, K>(array: T[], keyFn?: Mapper<T, K>): [K, T[]][]; /** * Returns a function that * creates partitions of an `array` by the key extracted from each item by a function `keyFn`. * @param keyFn Function that extracts a key from each item. Default: `identity`. */ export declare function partition<T, K>(keyFn?: Mapper<T, K>): typeof deferred; /** * Creates partitions of an `array` by the key extracted from each item by a previously defined function `keyFn`. * @param array Array to partition. */ declare function deferred<T, K>(array: T[]): [K, T[]][]; export {};