(color: string)
| 18 | // ─── Normalize ─────────────────────────────────────────────────────────────── |
| 19 | |
| 20 | export function normalizeHexColor(color: string): string { |
| 21 | if (typeof color !== "string") { |
| 22 | return ""; |
| 23 | } |
| 24 | |
| 25 | const trimmed = color.trim().toLowerCase(); |
| 26 | if (SIX_DIGIT_HEX.test(trimmed)) { |
| 27 | return trimmed; |
| 28 | } |
| 29 | |
| 30 | const shortMatch = THREE_DIGIT_HEX.exec(trimmed); |
| 31 | if (!shortMatch) { |
| 32 | return ""; |
| 33 | } |
| 34 | |
| 35 | const [, value] = shortMatch; |
| 36 | return `#${value[0]}${value[0]}${value[1]}${value[1]}${value[2]}${value[2]}`; |
| 37 | } |
| 38 | |
| 39 | export function toUniqueHexColors(colors: string[] = []): string[] { |
| 40 | const unique: string[] = []; |
no outgoing calls
no test coverage detected