refactor: clean up unused imports and improve file loading logic
This commit is contained in:
parent
4f54880400
commit
31a8d62f1d
4 changed files with 105 additions and 67 deletions
7
src/lib/misc.ts
Normal file
7
src/lib/misc.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
export function debounce<T extends (...args: any[]) => void>(fn: T, delay = 200) {
|
||||
let timer: ReturnType<typeof setTimeout> | null = null;
|
||||
return (...args: Parameters<T>) => {
|
||||
if (timer) clearTimeout(timer);
|
||||
timer = setTimeout(async () => await fn(...args), delay);
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue