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

bimap

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

Apply functions to both sides of an Either. The first function is applied to Left values, the second to Right values.

@example
import * as E from "./either.ts";
import { pipe } from "./fn.ts";

const result1 = pipe(
  E.right(21),
  E.bimap(
    (error) => `Error: ${error}`,
    (value) => value * 2
  )
);
// Right(42)

const result2 = pipe(
  E.left("Something failed"),
  E.bimap(
    (error) => `Error: ${error}`,
    (value) => value * 2
  )
);
// Left("Error: Something failed")
function bimap<A, B, I, J>(fbj: (b: B) => J, fai: (a: A) => I): (ta: Either<B, A>) => Either<J, I>;
§
bimap<A, B, I, J>(fbj: (b: B) => J, fai: (a: A) => I): (ta: Either<B, A>) => Either<J, I>
[src]

§Parameters

§
fbj: (b: B) => J
[src]
§
fai: (a: A) => I
[src]

§Return Type

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