Skip to main content
Module

x/hkts/option.ts>getOrElse

Functional programming tools: option, either, task, state, optics, etc.
Latest
variable getOrElse
import { getOrElse } from "https://deno.land/x/hkts@v0.0.52/option.ts";

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

type

<B>(onNone: () => B) => unknown