(raw: string)
| 147 | * Returns null for non-dimension strings (bare numbers, keywords like `auto`). |
| 148 | */ |
| 149 | export function parseDimensionParts(raw: string): { value: number; unit: string } | null { |
| 150 | if (typeof raw !== 'string') return null; |
| 151 | const match = raw.match(/^(-?\d*\.?\d+)([a-zA-Z%]+)$/); |
| 152 | if (!match) return null; |
| 153 | const value = parseFloat(match[1]!); |
| 154 | return Number.isNaN(value) ? null : { value, unit: match[2]! }; |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * Validate a hex color string. Accepts #RGB, #RGBA, #RRGGBB, and #RRGGBBAA. |
no outgoing calls
no test coverage detected
searching dependent graphs…