(n: number)
| 37 | }; |
| 38 | |
| 39 | function get256Color(n: number): string { |
| 40 | if (n < 16) return FG[n + 30] ?? FG[n + 82] ?? "#ffffff"; |
| 41 | if (n < 232) { |
| 42 | const i = n - 16; |
| 43 | const b = i % 6, g = Math.floor(i / 6) % 6, r = Math.floor(i / 36); |
| 44 | const h = (v: number) => (v === 0 ? 0 : 55 + v * 40).toString(16).padStart(2, "0"); |
| 45 | return `#${h(r)}${h(g)}${h(b)}`; |
| 46 | } |
| 47 | const gray = (n - 232) * 10 + 8; |
| 48 | const hex = gray.toString(16).padStart(2, "0"); |
| 49 | return `#${hex}${hex}${hex}`; |
| 50 | } |
| 51 | |
| 52 | interface AnsiStyle { |
| 53 | color?: string; |
no test coverage detected