Skip to content

Instantly share code, notes, and snippets.

@Jon-Alonso
Created January 23, 2018 03:13
Show Gist options
  • Select an option

  • Save Jon-Alonso/1862823bd4ddd59cd770b4b42fe8b804 to your computer and use it in GitHub Desktop.

Select an option

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