Skip to content

Instantly share code, notes, and snippets.

@leolanese
Created August 12, 2020 20:39
Show Gist options
  • Save leolanese/6c967ec4efe4df9f0d62f3ed0a84652f to your computer and use it in GitHub Desktop.
Save leolanese/6c967ec4efe4df9f0d62f3ed0a84652f to your computer and use it in GitHub Desktop.
debounce js
const debounce = (fn, time) => {
let timerId;
return function(...args) {
const functionCall = () => fn.apply(this, args);
clearTimeout(timerId);
timerId = setTimeout(functionCall, time);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment