| 34 | ]) |
| 35 | |
| 36 | function getColor (color) { |
| 37 | const colorDepth = depth.getColorDepth() |
| 38 | if (!colors256.has(color)) { |
| 39 | throw new Errors({ color }).invalidColor() |
| 40 | } |
| 41 | if (colorDepth >= 24 && colorsTrueColor.has(color)) { |
| 42 | const [r, g, b] = colorsTrueColor.get(color) |
| 43 | return (message) => `\x1b[38;2;${r};${g};${b}m${message}\x1b[39m` |
| 44 | } |
| 45 | if (colorDepth >= 8) { |
| 46 | const code = colors256.get(color) |
| 47 | return (message) => `\x1b[38;5;${code}m${message}\x1b[39m` |
| 48 | } |
| 49 | if (colorDepth >= 4) { |
| 50 | const code = colors16.get(color) |
| 51 | return (message) => `\x1b[${code}m${message}\x1b[39m` |
| 52 | } |
| 53 | return (message) => message |
| 54 | } |
| 55 | |
| 56 | function bold (message) { |
| 57 | if (depth.getColorDepth() >= 4) { |