MCPcopy Create free account
hub / github.com/bytebase/bytebase / parse

Function parse

frontend/tests/e2e/sql-editor/sql-editor-admin-mode.spec.ts:175–193  ·  view source on GitHub ↗
(s: string)

Source from the content-addressed store, hash-verified

173 // oklab L is 0–1 — both map linearly to 0–255, plenty for the harmony
174 // assertion below.
175 const parse = (s: string) => {
176 const rgb = s.match(/rgba?\(([^)]+)\)/);
177 if (rgb) {
178 const parts = rgb[1].split(",").map((p) => parseFloat(p.trim()));
179 return { r: parts[0], g: parts[1], b: parts[2], a: parts[3] ?? 1 };
180 }
181 const oklab = s.match(/^oklab\(\s*([\d.\-]+)/);
182 if (oklab) {
183 const gray = Math.round(parseFloat(oklab[1]) * 255);
184 return { r: gray, g: gray, b: gray, a: 1 };
185 }
186 const lab = s.match(/^lab\(\s*([\d.\-]+)\s+([\d.\-]+)\s+([\d.\-]+)/);
187 if (lab) {
188 const L = parseFloat(lab[1]);
189 const gray = Math.round((L / 100) * 255);
190 return { r: gray, g: gray, b: gray, a: 1 };
191 }
192 return null;
193 };
194 const shellRgb = parse(shellBg);
195 const blockRgb = parse(blockBg);
196

Callers 6

PrettyJSONFunction · 0.85
safeReadFunction · 0.85
safeReadFunction · 0.85
ExplainVisualizerAppFunction · 0.85
safeReadJSONFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected