Created
January 13, 2024 21:11
-
-
Save Drew-Killeen/1dfb8a535eb17a78529c9c560e7362b5 to your computer and use it in GitHub Desktop.
TypeScript Throttle Function
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(callback: Function, time: number, throttlePause: boolean) { | |
if (throttlePause) { | |
return; | |
} | |
throttlePause = true; | |
setTimeout(() => { | |
callback(); | |
throttlePause = false; | |
}, time); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment