UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

17 lines 389 B
//#region src/function/once.d.ts /** * `once(fn)` * * Creates a function that executes only once and caches the result for subsequent calls. * * ```ts * const expensive = once(() => { * console.log("Computing..."); * return 42; * }); * * expensive(); // logs "Computing..." and returns 42 */ declare function once<T>(fn: () => T): () => T; //#endregion export { once };