MCPcopy Create free account
hub / github.com/codeaashu/claude-code / parseParams

Function parseParams

src/ink/termio/sgr.ts:41–77  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

39type Param = { value: number | null; subparams: number[]; colon: boolean }
40
41function parseParams(str: string): Param[] {
42 if (str === '') return [{ value: 0, subparams: [], colon: false }]
43
44 const result: Param[] = []
45 let current: Param = { value: null, subparams: [], colon: false }
46 let num = ''
47 let inSub = false
48
49 for (let i = 0; i <= str.length; i++) {
50 const c = str[i]
51 if (c === ';' || c === undefined) {
52 const n = num === '' ? null : parseInt(num, 10)
53 if (inSub) {
54 if (n !== null) current.subparams.push(n)
55 } else {
56 current.value = n
57 }
58 result.push(current)
59 current = { value: null, subparams: [], colon: false }
60 num = ''
61 inSub = false
62 } else if (c === ':') {
63 const n = num === '' ? null : parseInt(num, 10)
64 if (!inSub) {
65 current.value = n
66 current.colon = true
67 inSub = true
68 } else {
69 if (n !== null) current.subparams.push(n)
70 }
71 num = ''
72 } else if (c >= '0' && c <= '9') {
73 num += c
74 }
75 }
76 return result
77}
78
79function parseExtendedColor(
80 params: Param[],

Callers 1

applySGRFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected