flatmap
import { flatmap } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/record.ts";Apply a function to each value and key in a ReadonlyRecord, where each application returns a new ReadonlyRecord, then flatten all resulting records into a single ReadonlyRecord. If multiple records contain the same key, later values will overwrite earlier ones.
@example
import * as R from "./record.ts";
import { pipe } from "./fn.ts";
const result = pipe(
{ a: 1, b: 2 },
R.flatmap((n, key) => ({ [key]: n, [`${key}_doubled`]: n * 2 })),
); // { a: 1, a_doubled: 2, b: 2, b_doubled: 4 }
function flatmap<A, I>(fati: (a: A, i: string) => ReadonlyRecord<I>): (ua: ReadonlyRecord<A>) => ReadonlyRecord<I>;
§
flatmap<A, I>(fati: (a: A, i: string) => ReadonlyRecord<I>): (ua: ReadonlyRecord<A>) => ReadonlyRecord<I>
[src]§Parameters
§
fati: (a: A, i: string) => ReadonlyRecord<I>
[src]§Return Type
§
(ua: ReadonlyRecord<A>) => ReadonlyRecord<I>
[src]