Created
October 8, 2019 18:40
-
-
Save pseudosavant/83174920102d6a2aa9acb7f06d161be2 to your computer and use it in GitHub Desktop.
Really basic throttling function that returns a throttled function wrapped around the provided function
This file contains hidden or 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(fn, duration) { | |
var t; | |
return function(...args) { | |
clearTimeout(t); | |
t = setTimeout(fn.bind(null, ...args), duration); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment