Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/rimbu/core/main/index.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/core/main/index.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/core/main/index.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