Created
December 13, 2022 17:33
-
-
Save mainendra/18eff704a4a2ba1aaf536bfda72227d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function debounce<T extends [...T], U>(callback: (...args: [...T]) => U, delayMs: number): (...args: [...T]) => void { | |
let timerId: any = null; | |
return (...args: [...T]) => { | |
clearTimeout(timerId); | |
timerId = setTimeout(() => callback(...args), delayMs); | |
}; | |
} | |
export { | |
debounce | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment