Skip to content

Instantly share code, notes, and snippets.

@Takaitra
Forked from Jon-Alonso/debounce.js
Last active May 10, 2018 18:58
Show Gist options
  • Select an option

  • Save Takaitra/78021a60e3ba75a8bcdfd20c0cec06bd to your computer and use it in GitHub Desktop.

Select an option

Save Takaitra/78021a60e3ba75a8bcdfd20c0cec06bd to your computer and use it in GitHub Desktop.
ES6 Debounce function
export function debounce (func, delay = 500) {
let timeout;
return function (...args) {
clearTimeout(timeout);
timeout = setTimeout(() => { func.apply(this, args) }, delay);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment