feat: initialise template

This commit is contained in:
etwodev
2025-11-11 15:19:09 +00:00
commit 911693f3c3
74 changed files with 8676 additions and 0 deletions

26
src/lib/utils/debounce/index.ts Executable file
View File

@@ -0,0 +1,26 @@
/**
* Debounce helper util
*
* This method will debounce calls made to the callback using the timeout
* provided. Set immediate to `true` to run the function immediately, then
* debounce further calls.
*/
export const debounce = <T extends (...args: unknown[]) => unknown>(
callBack: T,
wait: number,
immediate = false,
): VoidFunction => {
let timeout: NodeJS.Timeout | null;
return (...params: unknown[]): void => {
const args = params;
const later = (): void => {
timeout = null;
if (!immediate) callBack(...args);
};
const callNow = immediate && !timeout;
if (timeout) clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) callBack(...args);
};
};