Skip to content

Instantly share code, notes, and snippets.

@frosa-logrise
Created January 13, 2023 12:35
Show Gist options
  • Save frosa-logrise/2d7c9b123d0c871f83a0f703417a5a35 to your computer and use it in GitHub Desktop.
Save frosa-logrise/2d7c9b123d0c871f83a0f703417a5a35 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