Skip to content

Instantly share code, notes, and snippets.

@andhikayuana
Created February 23, 2020 14:24
Show Gist options
  • Save andhikayuana/a2bf33c15f7a88dae42e4e8758b651b2 to your computer and use it in GitHub Desktop.
Save andhikayuana/a2bf33c15f7a88dae42e4e8758b651b2 to your computer and use it in GitHub Desktop.
Simple debounce library
module.exports = function debounce (fn, delay = 500) {
var timeoutID = null
return function () {
clearTimeout(timeoutID)
var args = arguments
var that = this
timeoutID = setTimeout(function () {
fn.apply(that, args)
}, delay)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment