Skip to main content
Module

x/rimbu/mod.ts>OptLazyOr

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
type alias OptLazyOr
import { type OptLazyOr } from "https://deno.land/x/rimbu@0.13.1/mod.ts";

A potentially lazy value that, in case of a lazy function, received a default value that it can return.

definition: T | ((none: O) => T | O)
function OptLazyOr
import { OptLazyOr } from "https://deno.land/x/rimbu@0.13.1/mod.ts";

Returns the value contained in an OptLazyOr instance of type T, or the given otherValue if the lazy function returns it.

Examples

Example 1

OptLazyOr(1, 'a')               // => 1
OptLazyOr(() => 1, 'a')         // => 1
OptLazyOr((none) => none, 'a')  // => 'a'

Parameters

optLazyOr: OptLazyOr<T, O>
  • a value or a function returning a value or otherwise the received value
otherValue: O
  • the value to return if the optLazyOr does not return its own value