* Advance from `start` by `step(...)`, then extend up to 8 more characters to * land just past the next word/punctuation boundary so the reveal lands on a * whole word rather than mid-token.
(text: string, start: number)
| 30 | * whole word rather than mid-token. |
| 31 | */ |
| 32 | function nextIndex(text: string, start: number): number { |
| 33 | const end = Math.min(text.length, start + step(text.length - start)) |
| 34 | const max = Math.min(text.length, end + 8) |
| 35 | for (let i = end; i < max; i++) { |
| 36 | if (SNAP.test(text[i] ?? '')) return i + 1 |
| 37 | } |
| 38 | return end |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Content already longer than this when streaming begins is assumed to be |