Last active
July 25, 2021 03:14
-
-
Save Jaezmien/47f0fa638335557aa489c44e19e17669 to your computer and use it in GitHub Desktop.
⏱ Small 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
const debounce = function(f, t) { | |
let id; | |
return function() { | |
if( id ) clearTimeout(id); | |
id = setTimeout(() => {id = null; f()}, t); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment