Skip to content

Instantly share code, notes, and snippets.

@ChangJoo-Park
Created January 21, 2019 09:57
Show Gist options
  • Save ChangJoo-Park/fcede4d0111e83d9d8b9f2a191fa6589 to your computer and use it in GitHub Desktop.
Save ChangJoo-Park/fcede4d0111e83d9d8b9f2a191fa6589 to your computer and use it in GitHub Desktop.
debounce.js
const debounce = function (func, threshold) {
let timeout
return function () {
let context = this
let args = arguments
if (timeout) {
clearTimeout(timeout)
}
timeout = setTimeout(function () {
func.apply(context, args)
timeout = null
}, threshold)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment