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

Map over the left and right return values of a FnEither.

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

const boundedValue = (n: number) => n > 10 || n < 0 ? E.left(n) : E.right(n);

const log = pipe(
  boundedValue,
  FE.bimap(n => `Out of bounds: ${n}`, n => `Received a good value: ${n}`),
);

const result1 = log(1); // Right("Received a good value: 1")
const result2 = log(20); // Left("Out of bounds: 20")
function bimap<A, I, B, J>(fbj: (b: B) => J, fai: (a: A) => I): <D = unknown>(ua: FnEither<D, B, A>) => FnEither<D, J, I>;
§
bimap<A, I, B, J>(fbj: (b: B) => J, fai: (a: A) => I): <D = unknown>(ua: FnEither<D, B, A>) => FnEither<D, J, I>
[src]

§Parameters

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

§Return Type

§
<D = unknown>(ua: FnEither<D, B, A>) => FnEither<D, J, I>
[src]