es-toolkit
Version:
A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.
18 lines • 557 B
text/typescript
//#region src/function/once.d.ts
/**
* Creates a function that is restricted to invoking func once. Repeat calls to the function return the value of the first invocation.
*
* @template F - The type of the function.
* @param func - The function to restrict.
* @returns Returns the new restricted function.
*
* @example
* const initialize = once(createApplication);
*
* initialize();
* initialize();
* // => `createApplication` is invoked once
*/
declare function once<F extends (...args: any[]) => any>(func: F): F;
//#endregion
export { once };