(fn: () => void, ms: number)
| 77 | /** A trailing debouncer: N rapid calls collapse into one invocation after `ms` of quiet. |
| 78 | * Returned function exposes `.cancel()` to clear a pending call (used on close). */ |
| 79 | export function makeDebouncer(fn: () => void, ms: number): (() => void) & { cancel: () => void } { |
| 80 | let timer: ReturnType<typeof setTimeout> | null = null; |
| 81 | const debounced = () => { |
| 82 | if (timer) clearTimeout(timer); |
| 83 | timer = setTimeout(() => { timer = null; fn(); }, ms); |
| 84 | }; |
| 85 | debounced.cancel = () => { if (timer) { clearTimeout(timer); timer = null; } }; |
| 86 | return debounced; |
| 87 | } |
| 88 | |
| 89 | /** Build the page served for GET / : current version → preview HTML → live-reload injected. |
| 90 | * Any failure becomes a valid error-overlay page (still hashable, still self-recovering). */ |
no outgoing calls
no test coverage detected