Skip to content

Instantly share code, notes, and snippets.

@jarretmoses
Created October 29, 2019 15:49
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 jarretmoses/d9166ac2d429d404230d8f4de9ca54c1 to your computer and use it in GitHub Desktop.
Save jarretmoses/d9166ac2d429d404230d8f4de9ca54c1 to your computer and use it in GitHub Desktop.
Debounce from Scratch
const debounce = (callback, wait) => {
let timeout = null;
return (...args) => {
clearTimeout(timeout);
timeout = setTimeout(() => {
callback.apply(this, args);
}, wait);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment