MCPcopy Index your code
hub / github.com/darkreader/darkreader / parseRGB

Function parseRGB

src/utils/color.ts:366–372  ·  view source on GitHub ↗
($rgb: string)

Source from the content-addressed store, hash-verified

364}
365
366function parseRGB($rgb: string): RGBA | null {
367 const [r, g, b, a = 1] = getNumbersFromString($rgb, rgbRange, rgbUnits);
368 if (r == null || g == null || b == null || a == null) {
369 return null;
370 }
371 return {r, g, b, a};
372}
373
374const hslRange = [360, 1, 1, 1];
375const hslUnits = {'%': 100, 'deg': 360, 'rad': 2 * Math.PI, 'turn': 1};

Callers 2

parseFunction · 0.85
domParseColorFunction · 0.85

Calls 1

getNumbersFromStringFunction · 0.85

Tested by

no test coverage detected