Created
December 4, 2024 11:10
-
-
Save KutayGuler/b742f3074eaf332306dfa7ed45809868 to your computer and use it in GitHub Desktop.
debounce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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