Skip to content

Instantly share code, notes, and snippets.

@david-mateogit
Created March 20, 2020 02:25
Show Gist options
  • Save david-mateogit/a72292f4b069ee7f9fbf5ec01b76c11b to your computer and use it in GitHub Desktop.
Save david-mateogit/a72292f4b069ee7f9fbf5ec01b76c11b to your computer and use it in GitHub Desktop.
Basic debounce function
function debounce(func, duration) {
let timeout;
return function(...args) => {
const effect = () => {
timeout = null;
return func.apply(this, 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