Last active
May 28, 2019 15:24
-
-
Save vinicius5581/85e28d74259f4dce3649f7acc32da610 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, time) => { | |
let timerId = null | |
return (...args) => { | |
if (timerId) { | |
clearTimeout(timeId) | |
} | |
timeId = setTimeout(() => { | |
fn(...args) | |
}, time) | |
} | |
} | |
input.addEventListener('keyup', debounce(e => console.log(e), 1000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment