• Transforms the optional value into Result with the error e.

    Type Parameters

    • E

    Parameters

    • e: E

      The error used when opt is a None.

    Returns (<T>(opt) => Result<E, T>)

    The new Result.

    Examples

    import { okOr, some, none } from "./option.ts";
    import { err, ok } from "./result.ts";
    import { assertEquals } from "../deps.ts";

    const orZero = okOr(0);

    assertEquals(orZero(some("foo")), ok("foo"));
    assertEquals(orZero(none()), err(0));

Generated using TypeDoc