Skip to content

Instantly share code, notes, and snippets.

@dSalieri
Created July 23, 2021 16:42
Show Gist options
  • Save dSalieri/67be2a406ce4001944ea28ec07d84847 to your computer and use it in GitHub Desktop.
Save dSalieri/67be2a406ce4001944ea28ec07d84847 to your computer and use it in GitHub Desktop.
Light template of throttle
function throttle(func, delay) {
let timerId;
return function (args) {
if (timerId == null) {
func(args);
timerId = setTimeout(function () {
timerId = null;
}, delay);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment