import { unwrapOr } from "https://deno.land/x/result_js@2.0.0/operators/extract.ts";
Returns the contained Ok
value, otherwise defaultValue
.
Examples
Example 1
Example 1
import { Ok, Err } from "https://deno.land/x/result_js/spec.ts";
import { unwrapOr } from "https://deno.land/x/result_js/mod.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
assertEquals(unwrapOr(Ok(0), 1), 0);
assertEquals(unwrapOr(Err(1), 1), 1);