Skip to content

Instantly share code, notes, and snippets.

@leonidkuznetsov18
Created April 30, 2020 18:17
Show Gist options
  • Select an option

  • Save leonidkuznetsov18/0041ec400cf243d59a8ef13b28882e44 to your computer and use it in GitHub Desktop.

Select an option

Save leonidkuznetsov18/0041ec400cf243d59a8ef13b28882e44 to your computer and use it in GitHub Desktop.
simple debounce
const debounce = (fn, wait = 1) => {
let timeout = 0;
return function (...args) {
clearTimeout(timeout);
timeout = setTimeout(() => fn.call(this, ...args), wait)
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment