Created
July 27, 2017 23:08
-
-
Save yyssjj33/d640eaf606e1a07e9c15d92aa7a3bc3d 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
const debounce = (fn, wait) => { | |
let timeout = null; | |
wait = wait || 250; // Default to 250ms | |
return (...args) => { | |
const delayed = () => { | |
timeout = null; | |
fn.apply(null, args); | |
}; | |
clearTimeout(timeout); | |
timeout = setTimeout(delayed, wait); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment