MCPcopy
hub / github.com/google-labs-code/design.md / parseDimensionParts

Function parseDimensionParts

packages/cli/src/linter/model/spec.ts:149–155  ·  view source on GitHub ↗
(raw: string)

Source from the content-addressed store, hash-verified

147 * Returns null for non-dimension strings (bare numbers, keywords like `auto`).
148 */
149export 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.

Callers 4

isStandardDimensionFunction · 0.85
isParseableDimensionFunction · 0.85
spec.test.tsFile · 0.85
parseDimensionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…