Skip to content

Instantly share code, notes, and snippets.

@SadPandaBear
Created April 13, 2018 13:41
Show Gist options
  • Save SadPandaBear/a2493e353713b0fc79d2af272dd12cef to your computer and use it in GitHub Desktop.
Save SadPandaBear/a2493e353713b0fc79d2af272dd12cef to your computer and use it in GitHub Desktop.
const throttle = (time, f) => (...args) => {
const now = Date.now()
return () => {
if ((now + time - Date.now()) < 0) {
f(...args)
now = Date.now()
}
}
}
export default throttle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment