( func: T, milliseconds: number )
| 59 | }; |
| 60 | |
| 61 | export const debounce = <T extends (...args: any[]) => any>( |
| 62 | func: T, |
| 63 | milliseconds: number |
| 64 | ) => { |
| 65 | let timer: Timeout | undefined; |
| 66 | |
| 67 | return function f(this: unknown, ...args: Parameters<T>): void { |
| 68 | if (timer) { |
| 69 | clearTimeout(timer); |
| 70 | } |
| 71 | timer = setTimeout(() => func.call(this, ...args), milliseconds); |
| 72 | }; |
| 73 | }; |
| 74 | |
| 75 | // debounce an async func. once an async func canceled, it throws a exception |
| 76 | export const debounceAsyncFunc = <T extends (...args: any[]) => Promise<any>>( |
nothing calls this directly
no outgoing calls
no test coverage detected