Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

once

Creates a function that will only execute the provided function once. Subsequent calls will return the cached result from the first execution.

@example
const getValue = once(() => expensiveOperation())
getValue() // executes expensiveOperation
getValue() // returns cached result
function once<T>(fn: () => T): () => T;
§
once<T>(fn: () => T): () => T
[src]

§Type Parameters

§Parameters

§
fn: () => T
[src]

The function to execute once

§Return Type

§
() => T
[src]

A function that will only execute the provided function once