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

x/rimbu/common/async-optlazy.ts>AsyncOptLazy.toMaybePromise

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
function AsyncOptLazy.toMaybePromise
import { AsyncOptLazy } from "https://deno.land/x/rimbu@1.2.0/common/async-optlazy.ts";
const { toMaybePromise } = AsyncOptLazy;

Returns the value or promised value contained in an AsyncOptLazy instance of type T.

Examples

Example 1

AsyncOptLazy.toMaybePromise(1)              // => 1
AsyncOptLazy.toMaybePromise(() => 1)        // => 1
AsyncOptLazy.toMaybePromise(() => () => 1)  // => () => 1
AsyncOptLazy.toMaybePromise(async () => 1)  // => Promise(1)
AsyncOptLazy.toMaybePromise(Promise.resolve(1))  // => Promise(1)

Type Parameters

T
optional
A extends any[] = []

Parameters

optLazy: AsyncOptLazy<T, A>
  • the AsyncOptLazy value of type T
...args: A
  • when needed, the extra arguments to pass to the lazy invocation