()
| 43 | }); |
| 44 | /** Fire the newest live timer, as the browser would when its time comes. */ |
| 45 | const fire = async (): Promise<void> => { |
| 46 | const live = timers.filter((timer) => !timer.cancelled); |
| 47 | const timer = live[live.length - 1]; |
| 48 | if (timer === undefined) { |
| 49 | throw new Error('no timer armed'); |
| 50 | } |
| 51 | timer.cancelled = true; |
| 52 | timer.fn(); |
| 53 | await Promise.resolve(); |
| 54 | await Promise.resolve(); |
| 55 | }; |
| 56 | return { buffer, posts, timers, fire }; |
| 57 | } |
| 58 |