import { option } from "https://deno.land/x/fun@v2.0.0-alpha.6/mod.ts";
const { getOrElse } = option;
getOrElse operates like a simplified fold. One supplies a thunk that returns a default inner value of the Option for the cases where the option is None.
Examples
const toNumber = getOrElse(() => 0);
const a = toNumber(some(1)); // 1
const b = toNumber(none); // 0
const toNumber = getOrElse(() => 0); const a = toNumber(some(1)); // 1 const b = toNumber(none); // 0
Parameters
onNone: () => B