Skip to content

Instantly share code, notes, and snippets.

@KutayGuler
Created December 4, 2024 11:10
Show Gist options
  • Save KutayGuler/b742f3074eaf332306dfa7ed45809868 to your computer and use it in GitHub Desktop.
Save KutayGuler/b742f3074eaf332306dfa7ed45809868 to your computer and use it in GitHub Desktop.
debounce
export function debounce(fn: Function, ms: number) {
// @ts-expect-error
let timeout: NodeJS.Timeout;
return function () {
clearTimeout(timeout);
// @ts-expect-error
timeout = setTimeout(() => fn.apply(this, arguments), ms);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment