Last active
October 9, 2020 12:01
-
-
Save apappas1129/4929e3217ac54e047ba9d4ff519a554b to your computer and use it in GitHub Desktop.
Your vanilla JS debounce π! Grabbed it from https://gist.githubusercontent.com/peduarte/7ee475dd0fae1940f857582ecbb9dc5f/raw/3329385ec7436ee361713eb30db8b9b0b4eb2c98/transpiled.js
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
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