Last active
January 15, 2024 15:35
-
-
Save Drew-Killeen/e068372199a9bb4265aa793ebe68c2fb to your computer and use it in GitHub Desktop.
TypeScript debounce function
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 (callback: Function, duration: number, timer: number) { | |
if (timer) { | |
clearTimeout(timer); | |
} | |
timer = setTimeout(callback, duration); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment