import { unwrapOrElse } from "https://deno.land/x/result_js@2.0.0/mod.ts";
Returns the contained Ok
value, otherwise computes it from a closure.
Examples
Example 1
Example 1
import { Ok, Err } from "https://deno.land/x/result_js/spec.ts";
import { unwrapOrElse } from "https://deno.land/x/result_js/operators/extract.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
assertEquals(unwrapOrElse(Ok(0), () => 2 ** 3), 0);
assertEquals(unwrapOrElse(Err(1), () => 2 ** 3), 8);