import { mapOr } from "https://deno.land/x/optio@1.0.0/operators/transform.ts";
Returns the provided default value (if None
), or applies a function to the contained value (if Some
).
Examples
Example 1
Example 1
import { mapOr, Option, Some } from "https://deno.land/x/optio/mod.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
const option: Option<string> = Some("Hello");
assertEquals(mapOr(option, 0, ({ length }) => length), 5);