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

Fold an Either into a single value by providing functions for both Left and Right cases, along with an initial value.

@example
import * as E from "./either.ts";

const foldResult = E.fold(
  (acc: string, value: number) => `${acc}, ${value}`,
  "Values:"
);

const result1 = foldResult(E.right(42));
// "Values:, 42"

const result2 = foldResult(E.left("error"));
// "Values:"
function fold<A, O>(foao: (o: O, a: A) => O, o: O): <B>(ta: Either<B, A>) => O;
§
fold<A, O>(foao: (o: O, a: A) => O, o: O): <B>(ta: Either<B, A>) => O
[src]

§Type Parameters

§Parameters

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

§Return Type

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