(time: number, cb: () => void)
| 520 | } |
| 521 | |
| 522 | function debounce(time: number, cb: () => void) { |
| 523 | let timer: ReturnType<typeof globalThis.setTimeout> | null |
| 524 | return () => { |
| 525 | if (timer) { |
| 526 | globalThis.clearTimeout(timer) |
| 527 | timer = null |
| 528 | } |
| 529 | timer = globalThis.setTimeout(cb, time) |
| 530 | } |
| 531 | } |