Skip to content

Instantly share code, notes, and snippets.

@apappas1129
Last active October 9, 2020 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apappas1129/4929e3217ac54e047ba9d4ff519a554b to your computer and use it in GitHub Desktop.
Save apappas1129/4929e3217ac54e047ba9d4ff519a554b to your computer and use it in GitHub Desktop.
export default function debounce(func) {
var wait =
arguments.length <= 1 || arguments[1] === undefined ? 100 : arguments[1]
var timeout = void 0
return function () {
var _this = this
for (
var _len = arguments.length, args = Array(_len), _key = 0;
_key < _len;
_key++
) {
args[_key] = arguments[_key]
}
clearTimeout(timeout)
timeout = setTimeout(function () {
func.apply(_this, args)
}, wait)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment