MCPcopy Create free account
hub / github.com/ecomfe/tempad-dev / parseGradient

Function parseGradient

packages/extension/mcp/tools/code/styles/background.ts:264–289  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

262}
263
264function parseGradient(value: string): { fn: string; args: string[] } | null {
265 const match = value.match(GRADIENT_FN_RE)
266 if (!match || match.index == null) return null
267
268 const fn = match[1]
269 const start = value.indexOf('(', match.index)
270 if (start < 0) return null
271
272 let depth = 0
273 let end = -1
274 for (let i = start; i < value.length; i += 1) {
275 const ch = value[i]
276 if (ch === '(') depth += 1
277 else if (ch === ')') {
278 depth -= 1
279 if (depth === 0) {
280 end = i
281 break
282 }
283 }
284 }
285 if (end < 0) return null
286
287 const inner = value.slice(start + 1, end)
288 return { fn, args: splitByTopLevelComma(inner) }
289}
290
291function formatPercent(pos: number): string {
292 const pct = Math.round(pos * 10000) / 100

Callers 1

Calls 1

splitByTopLevelCommaFunction · 0.90

Tested by

no test coverage detected