remeda
Version:
A utility library for JavaScript and Typescript.
16 lines (14 loc) • 438 B
text/typescript
/**
* Creates a function that is restricted to invoking `func` once. Repeat calls to the function return the value of the first invocation.
*
* @param fn - The function to wrap.
* @signature R.once(fn)
* @example
* const initialize = R.once(createApplication);
* initialize();
* initialize();
* // => `createApplication` is invoked once
* @category Function
*/
declare function once<T>(fn: () => T): () => T;
export { once };