Skip to content

Instantly share code, notes, and snippets.

@carlflor
Created May 30, 2022 08:48
Show Gist options
  • Save carlflor/360beb32911ecced875392631c7b2062 to your computer and use it in GitHub Desktop.
Save carlflor/360beb32911ecced875392631c7b2062 to your computer and use it in GitHub Desktop.
const debounce = (func, wait = 1000) => {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment