Last active
October 14, 2020 09:26
-
-
Save ashwinkumar2438/14cdf38f886344ed8177abc75d9d5369 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//takes function to be debounced and delay time to fire. | |
/*returns passed function wrapped with settimeout to delay fire | |
and updates to settimeout whenever called. */ | |
let debounce=(fn,timedelay)=>{ | |
let timerid=null; | |
return function(){ | |
clearTimeout(timerid); | |
timerid=setTimeout(fn.bind(this,...arguments),timedelay); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment