| 1708 | const pad = (width: number): string => pads[width] ?? (pads[width] = " ".repeat(width)) |
| 1709 | |
| 1710 | const printNumber = (value: number): string => { |
| 1711 | if (Number.isNaN(value)) return ".nan" |
| 1712 | if (value === Number.POSITIVE_INFINITY) return ".inf" |
| 1713 | if (value === Number.NEGATIVE_INFINITY) return "-.inf" |
| 1714 | if (Object.is(value, -0)) return "-0.0" |
| 1715 | return String(value) |
| 1716 | } |
| 1717 | |
| 1718 | // Use a literal block only when lines need no escaping or surrounding-whitespace preservation. |
| 1719 | const literalBlock = (text: string): { readonly header: string; readonly lines: Array<string> } | undefined => { |