(fn: () => boolean, ms = 4000)
| 23 | }); |
| 24 | |
| 25 | async function waitUntil(fn: () => boolean, ms = 4000): Promise<boolean> { |
| 26 | const t0 = Date.now(); |
| 27 | while (Date.now() - t0 < ms) { |
| 28 | if (fn()) return true; |
| 29 | await new Promise(r => setTimeout(r, 25)); |
| 30 | } |
| 31 | return fn(); |
| 32 | } |
| 33 | |
| 34 | /** Consume an SSE channel, counting `reload` events. Returns a stop() fn. */ |
| 35 | async function openSse(url: string, onReload: () => void): Promise<() => void> { |
no outgoing calls
no test coverage detected