( func: T, delay: number )
| 1 | type DebounceFunction<T = unknown> = (...args: Array<T>) => void; |
| 2 | |
| 3 | export const debounce = <T extends DebounceFunction>( |
| 4 | func: T, |
| 5 | delay: number |
| 6 | ): ((...args: Parameters<T>) => void) => { |
| 7 | let timeoutId: NodeJS.Timeout; |
| 8 | |
| 9 | return (...args: Parameters<T>) => { |
| 10 | clearTimeout(timeoutId); |
| 11 | |
| 12 | timeoutId = setTimeout(() => { |
| 13 | func(...args); |
| 14 | }, delay); |
| 15 | }; |
| 16 | }; |
| 17 | |
| 18 | export function deepMerge<Obj1 extends object, Obj2 extends object>( |
| 19 | obj1: Obj1, |