mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-31 22:43:11 +02:00
Move some things around
This commit is contained in:
11
src-web/lib/debounce.ts
Normal file
11
src-web/lib/debounce.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export function debounce(fn: (...args: any[]) => any, delay: number) {
|
||||
let timer: ReturnType<typeof setTimeout>;
|
||||
const result = function (...args: Parameters<typeof fn>) {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => fn(...args), delay);
|
||||
};
|
||||
result.cancel = function () {
|
||||
clearTimeout(timer);
|
||||
};
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user