Created
July 23, 2021 16:42
-
-
Save dSalieri/67be2a406ce4001944ea28ec07d84847 to your computer and use it in GitHub Desktop.
Light template of throttle
This file contains 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
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