Skip to content

Instantly share code, notes, and snippets.

@andreasvirkus
Created June 12, 2021 17:12
Show Gist options
  • Save andreasvirkus/acce53d389de09cbdb537217db2dd6ed to your computer and use it in GitHub Desktop.
Save andreasvirkus/acce53d389de09cbdb537217db2dd6ed to your computer and use it in GitHub Desktop.
A modern twist to an oldie, but goldie.
export 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