( func: T, wait: number )
| 6 | */ |
| 7 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 8 | export default function debounce<T extends (...args: any[]) => void>( |
| 9 | func: T, |
| 10 | wait: number |
| 11 | ): (...args: Parameters<T>) => void { |
| 12 | let timeoutId: ReturnType<typeof setTimeout> | undefined; |
| 13 | |
| 14 | return function debounced(this: unknown, ...args: Parameters<T>): void { |
| 15 | clearTimeout(timeoutId); |
| 16 | timeoutId = setTimeout(() => { |
| 17 | func.apply(this, args); |
| 18 | }, wait); |
| 19 | }; |
| 20 | } |
no outgoing calls
no test coverage detected