Skip to content

Instantly share code, notes, and snippets.

@intrnl
Last active November 17, 2019 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save intrnl/30e0e04ef46a441a6d7110b2c24b9cfa to your computer and use it in GitHub Desktop.
Save intrnl/30e0e04ef46a441a6d7110b2c24b9cfa to your computer and use it in GitHub Desktop.
Function throttling
function throttle (fn, ms) {
let throttled = false;
return function () {
const call = () => fn.apply(this, arguments);
if (throttled) return;
throttled = true;
setTimeout(() => throttled = false);
call();
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment