Skip to content

Instantly share code, notes, and snippets.

@farishan
Created August 19, 2023 05:06
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 farishan/57e3594dfd5e869a268c15292c7f1fa0 to your computer and use it in GitHub Desktop.
Save farishan/57e3594dfd5e869a268c15292c7f1fa0 to your computer and use it in GitHub Desktop.
function debounce(func, timeout = 300) {
let timer;
return (...args) => {
clearTimeout(timer);
timer = setTimeout(() => {
func.apply(this, args);
}, timeout);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment