Skip to content

Instantly share code, notes, and snippets.

@pseudosavant
Created October 8, 2019 18:40
Show Gist options
  • Save pseudosavant/83174920102d6a2aa9acb7f06d161be2 to your computer and use it in GitHub Desktop.
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
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