| 24 | |
| 25 | /** Assert stable block count never decreases during streaming */ |
| 26 | export function assertMonotonicStable( |
| 27 | snapshots: RehtmlResult[], |
| 28 | ): void { |
| 29 | let max = 0; |
| 30 | for (const snap of snapshots) { |
| 31 | if (snap.stable.length < max) { |
| 32 | throw new Error( |
| 33 | `Stable count regressed: ${snap.stable.length} < ${max}`, |
| 34 | ); |
| 35 | } |
| 36 | max = snap.stable.length; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | /** Count how many snapshots had incomplete trailing tags stripped */ |
| 41 | export function countIncompleteStrips(snapshots: RehtmlResult[]): number { |