(color: string)
| 134 | }; |
| 135 | |
| 136 | function rgbAnsi(color: string): number[] { |
| 137 | const hexCode = (COLOR_PALETTE as Record<string, string | undefined>)[color]; |
| 138 | |
| 139 | if (hexCode === undefined) return []; |
| 140 | |
| 141 | let rgb: number[] = []; |
| 142 | // Split the hex color strings with the format "#rrggbb" into an array of three hex numbers |
| 143 | let rgbArray = hexCode.match(/#([\da-f]{2})([\da-f]{2})([\da-f]{2})/i); |
| 144 | if (rgbArray !== null) { |
| 145 | rgb = rgbArray.slice(1).map((x) => parseInt(x, 16)); |
| 146 | } else { |
| 147 | rgbArray = hexCode.match(/#([\da-f])([\da-f])([\da-f])/i); |
| 148 | rgb = rgbArray!.slice(1).map((x) => 16 * parseInt(x, 16)); |
| 149 | } |
| 150 | |
| 151 | return rgb; |
| 152 | } |
| 153 | |
| 154 | export function ansiFgColor( |
| 155 | color: string | number, |
no test coverage detected