Project Init

This commit is contained in:
Muluhabt
2026-05-29 15:23:46 +03:00
commit 2fbc557aac
67387 changed files with 6063341 additions and 0 deletions

31
node_modules/es-toolkit/dist/function/once.mjs generated vendored Normal file
View File

@@ -0,0 +1,31 @@
//#region src/function/once.ts
/**
* Creates a function that is restricted to invoking the provided function `func` once.
* Repeated calls to the function will return the value from the first invocation.
*
* @template F - The type of function.
* @param {F} func - The function to restrict.
* @returns {F} A new function that invokes `func` once and caches the result.
*
* @example
* const initialize = once(() => {
* console.log('Initialized!');
* return true;
* });
*
* initialize(); // Logs: 'Initialized!' and returns true
* initialize(); // Returns true without logging
*/
function once(func) {
let called = false;
let cache;
return function(...args) {
if (!called) {
called = true;
cache = func(...args);
}
return cache;
};
}
//#endregion
export { once };