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/foldable.ts";

Collect all values from a Foldable structure using the provided Initializable.

@example
import { collect } from "./foldable.ts";
import * as A from "./array.ts";
import * as N from "./number.ts";

const numbers = [1, 2, 3, 4, 5];
const sum = collect(
  A.FoldableArray,
  N.InitializableNumberSum
)(numbers);

console.log(sum); // 15
function collect<U extends Kind, A>({ fold }: Foldable<U>, { combine, init }: Initializable<A>): <B = never, C = never, D = unknown, E = unknown>(ua: $<U, [A, B, C], [D], [E]>) => A;
§
collect<U extends Kind, A>({ fold }: Foldable<U>, { combine, init }: Initializable<A>): <B = never, C = never, D = unknown, E = unknown>(ua: $<U, [A, B, C], [D], [E]>) => A
[src]

§Type Parameters

§
U extends Kind
[src]

§Parameters

§
{ fold }: Foldable<U>
[src]
§
{ combine, init }: Initializable<A>
[src]

§Return Type

§
<B = never, C = never, D = unknown, E = unknown>(ua: $<U, [A, B, C], [D], [E]>) => A
[src]