Created
September 16, 2016 08:01
-
-
Save sms-system/37313fd3a3d542113dba9eb3cd2d102b to your computer and use it in GitHub Desktop.
Throttling 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
const throttle = (callback, limit) => { | |
let wait = false | |
return function() { | |
if (!wait) { | |
callback.call(this) | |
wait = true | |
setTimeout(() => wait = false, limit) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment