Last active
May 6, 2020 11:52
-
-
Save nicemaker/bc612b62c05b5af3be0d27f9677c0cf9 to your computer and use it in GitHub Desktop.
Debounce
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
export default function(f,ms){ | |
let t; | |
return (...args)=>{ | |
if( t ){ t = clearTimeout( t ); } | |
t = setTimeout( (args)=>{ | |
clearTimeout( t ); | |
f.apply( this,args ); | |
},ms ); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment