mirror of
https://github.com/harivansh-afk/asap.it.git
synced 2026-04-17 02:04:09 +00:00
first commit
This commit is contained in:
commit
1cdbffff09
200 changed files with 30007 additions and 0 deletions
17
app/utils/debounce.ts
Normal file
17
app/utils/debounce.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
export function debounce<Args extends any[]>(fn: (...args: Args) => void, delay = 100) {
|
||||
if (delay === 0) {
|
||||
return fn;
|
||||
}
|
||||
|
||||
let timer: number | undefined;
|
||||
|
||||
return function <U>(this: U, ...args: Args) {
|
||||
const context = this;
|
||||
|
||||
clearTimeout(timer);
|
||||
|
||||
timer = window.setTimeout(() => {
|
||||
fn.apply(context, args);
|
||||
}, delay);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue