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

fold

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

Fold over a These to produce a single value.

@example
import { fold, left, right, both } from "./these.ts";

const folder = fold(
  (acc: number, value: number) => acc + value,
  0
);

console.log(folder(left("Error"))); // 0
console.log(folder(right(5))); // 5
console.log(folder(both("Warning", 3))); // 3
function fold<A, O>(foao: (o: O, a: A) => O, o: O): <B>(ta: These<B, A>) => O;
§
fold<A, O>(foao: (o: O, a: A) => O, o: O): <B>(ta: These<B, A>) => O
[src]

§Type Parameters

§Parameters

§
foao: (o: O, a: A) => O
[src]

§Return Type

§
<B>(ta: These<B, A>) => O
[src]