(colorStr: string)
| 68 | const RGB_CACHE = new Map<string, RGBColorType | null>() |
| 69 | |
| 70 | export function parseRGB(colorStr: string): RGBColorType | null { |
| 71 | const cached = RGB_CACHE.get(colorStr) |
| 72 | if (cached !== undefined) return cached |
| 73 | |
| 74 | const match = colorStr.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/) |
| 75 | const result = match |
| 76 | ? { |
| 77 | r: parseInt(match[1]!, 10), |
| 78 | g: parseInt(match[2]!, 10), |
| 79 | b: parseInt(match[3]!, 10), |
| 80 | } |
| 81 | : null |
| 82 | RGB_CACHE.set(colorStr, result) |
| 83 | return result |
| 84 | } |
| 85 |
no test coverage detected