Skip to content

Instantly share code, notes, and snippets.

@kettanaito
Last active December 19, 2019 15:01
Show Gist options
  • Save kettanaito/ecbaf6f51856cfa1b986bef6a8027075 to your computer and use it in GitHub Desktop.
Save kettanaito/ecbaf6f51856cfa1b986bef6a8027075 to your computer and use it in GitHub Desktop.
Debounce
function debounce(func, duration) {
let timeout
return (...args) => {
const effect = () => {
timeout = null
return func(...args)
}
clearTimeout(timeout)
timeout = setTimeout(effect, duration)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment