Created
February 23, 2020 14:24
-
-
Save andhikayuana/a2bf33c15f7a88dae42e4e8758b651b2 to your computer and use it in GitHub Desktop.
Simple debounce library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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