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

Fold over a SyncEither to produce a single value.

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

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

const result1 = matcher(right(5)); // 5
const result2 = matcher(left("error")); // 0
function fold<A, O>(foao: (o: O, a: A) => O, o: O): <B>(ta: SyncEither<B, A>) => O;
§
fold<A, O>(foao: (o: O, a: A) => O, o: O): <B>(ta: SyncEither<B, A>) => O
[src]

§Type Parameters

§Parameters

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

§Return Type

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