Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

collect

import { collect } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/record.ts";

Collect all values in a ReadonlyRecord into a single value I by using a Combinable and a mapping function from A to I. This is effectively fold using a Combinable for the initial value.

@example
import * as R from "./record.ts";
import { InitializableNumberSum } from "./number.ts";
import { pipe } from "./fn.ts";

const collectSum = R.collect(InitializableNumberSum);
const collectLengths = collectSum((s: string) => s.length);

const result = collectLengths({ one: "one", two: "two" }); // 6
function collect<I>(M: Initializable<I>): <A>(fai: (a: A, index: string) => I) => (ua: ReadonlyRecord<A>) => I;
§
collect<I>(M: Initializable<I>): <A>(fai: (a: A, index: string) => I) => (ua: ReadonlyRecord<A>) => I
[src]

§Type Parameters

§Parameters

§Return Type

§
<A>(fai: (a: A, index: string) => I) => (ua: ReadonlyRecord<A>) => I
[src]