The function to provide a default value.
The mapped value or init
.
import { some, mapOrElse, none } from "./option.ts";
import { assertEquals } from "../deps.ts";
const strLenOrCalc = mapOrElse(() => 6 ** 4)((str: string) => str.length);
assertEquals(strLenOrCalc(some("Hello, World!")), 13);
assertEquals(strLenOrCalc(none()), 1296);
Generated using TypeDoc
Maps the optional value with a default value
fn()
.