• Returns resB if resA is an Err, otherwise returns the success resA. The order of arguments is reversed because of that it is useful for partial applying.

    Type Parameters

    • E

    • T

    Parameters

    • resB: Result<E, T>

      The second result.

    Returns (<F>(resA) => Result<E, T>)

    resA or resB.

    Examples

    import { err, ok, or } from "./result.ts";
    import { assertEquals } from "../deps.ts";

    const success = ok<number>(2);
    const failure = err<string>("not a 2");
    const lateError = err<string>("late error");
    const earlyError = err<string>("early error");
    const anotherSuccess = ok<number>(100);

    assertEquals(or<string, number>(lateError)(success), success);
    assertEquals(or<string, number>(success)(earlyError), success);
    assertEquals(or(lateError)(failure), lateError);
    assertEquals(or(anotherSuccess)(success), success);

Generated using TypeDoc