ts-prime
Version:
A utility library for JavaScript and Typescript.
18 lines • 1 kB
TypeScript
import { Pred } from './_types';
/**
* Loops each record element and maps against provided function.
* @param record The target object.
* @param fn Mapping function.
* @returns The new record.
* @signature
* P.flatMapRecord(record, fn)
* @signature
* P.flatMapRecord(record, fn)
* @example
* P.flatMapRecord({ a: 1, b: 2, c: 3 }, ([k,v]) => [[k, v * 2], [k + "_abc", v * 2]]) // => { a: 2, a_abc: 2, b: 4, b_abc: 4, c: 6, c_abc: 6 }
* P.flatMapRecord({ a: 1, b: 2, c: 3 }, ([k,v]) => [[k, v * 2], [k + "_abc", v * 2]]) // => { a: 2, a_abc: 2, b: 4, b_abc: 4, c: 6, c_abc: 6 }
* @category Object, Pipe
*/
export declare function mapRecord<T extends Record<string, unknown>, K extends string, V>(record: T, fn: Pred<[keyof T, T[keyof T]], [K, V]>): Record<K, V>;
export declare function mapRecord<T extends Record<string, unknown>, K extends string, V extends unknown>(fn: (v: [keyof T, T[keyof T]]) => [K, V]): (record: T) => Record<K, V>;
//# sourceMappingURL=mapRecord.d.ts.map