API reference › @evolu/common › Function › lazy
function lazy<T>(value: T): Lazy<T>;
Defined in: packages/common/src/Function.ts:159
Creates a Lazy from a precomputed value.
Use when the value is expensive to compute and want to compute it once at definition time rather than on every call.
Example
// Computed once at definition, returned on every call
const getConfig = lazy(parseConfig(rawConfig));
// vs. computed on every call
const getConfig = () => parseConfig(rawConfig);