Skip to content

Instantly share code, notes, and snippets.

@mr4torr
Created April 17, 2020 16:03
Show Gist options
  • Save mr4torr/5c76fbcd848ef72e81a3adb612b7ed10 to your computer and use it in GitHub Desktop.
Save mr4torr/5c76fbcd848ef72e81a3adb612b7ed10 to your computer and use it in GitHub Desktop.
debounce in javascript pure - es6
const debounceEvent = (fn, wait = 500, time) => (...args) => clearTimeout(time, time = setTimeout(() => fn(...args), wait))
/*
Example:
document.querySelector('input').addEventListener('keyup', debounceEvent((event) => console.log(event)))
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment