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

recover

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

Recover from a Left value by applying a function that returns an Either. Right values are unchanged.

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

const fallback = (error: string) => E.right(`Fallback: ${error}`);

const result1 = E.recover(fallback)(E.left("Something failed"));
// Right("Fallback: Something failed")

const result2 = E.recover(fallback)(E.right(42));
// Right(42)
function recover<B, I, J>(fbui: (b: B) => Either<J, I>): <A>(ua: Either<B, A>) => Either<J, A | I>;
§
recover<B, I, J>(fbui: (b: B) => Either<J, I>): <A>(ua: Either<B, A>) => Either<J, A | I>
[src]

§Type Parameters

§Parameters

§
fbui: (b: B) => Either<J, I>
[src]

§Return Type

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