Last active
July 28, 2022 17:05
-
-
Save jahilldev/4e8f2bd2bbb03edc47c4b3fa70f556eb to your computer and use it in GitHub Desktop.
Tiny JavaScript 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, frequency = 250, timer = null) { | |
return (...args) => ( | |
clearTimeout(timer), (timer = setTimeout(callback, frequency, ...args)) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment