function once
once<T>(fn: () => T): (() => T)

Lazy evaluation - compute once on first call, cache forever. Use instead of let x = null; const getX = () => x ??= compute();

Type Parameters

Parameters

fn: () => T

Return Type

(() => T)

Usage

import { once } from "docs/utilities.ts";