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.

Revisions

  1. mr4torr created this gist Apr 17, 2020.
    6 changes: 6 additions & 0 deletions debounceEvent.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    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)))
    */