• Unwraps the Ok value from a Result, or throws an error.

    Type Parameters

    • E

    • T

    Parameters

    • res: Result<E, T>

      The value which should be an Ok.

    Returns T

    The unwrapped item.

    Examples

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

    assertEquals(unwrap(ok(3)), 3);
    assertThrows(() => unwrap(err(4)), "unwrapped Err");

Generated using TypeDoc