MCPcopy Index your code
hub / github.com/adobe/react-spectrum / parse

Function parse

packages/@react-spectrum/s2/style/runtime.ts:84–133  ·  view source on GitHub ↗
(s: string)

Source from the content-addressed store, hash-verified

82}
83
84function parse(s: string) {
85 let properties = new Map<string, string>();
86 let i = 0;
87 while (i < s.length) {
88 while (i < s.length && s[i] === ' ') {
89 i++;
90 }
91
92 let start = i;
93 readValue(); // property index
94
95 // read conditions (up to the last segment)
96 let condition = i;
97 while (i < s.length && s[i] !== ' ') {
98 readValue();
99 }
100
101 let property = s.slice(start, condition);
102 if (process.env.NODE_ENV !== 'production' && property.startsWith('-macro-')) {
103 let value = s.slice(start, i);
104 properties.set(value, ' ' + value);
105 } else {
106 properties.set(property, (properties.get(property) || '') + ' ' + s.slice(start, i));
107 }
108 }
109
110 function readValue() {
111 if (s[i] === '-') {
112 // the beginning and end of arbitrary values are marked with -
113 while (i < s.length && s[i] !== ' ') {
114 i++;
115 if (s[i] === '-') {
116 i++;
117 break;
118 }
119 }
120 } else {
121 while (i < s.length) {
122 if (s[i] === '_') {
123 i++;
124 } else {
125 i++;
126 break;
127 }
128 }
129 }
130 }
131
132 return properties;
133}

Callers 2

mergeStylesFunction · 0.70
compileStringFunction · 0.50

Calls 3

sliceMethod · 0.80
readValueFunction · 0.70
setMethod · 0.45

Tested by

no test coverage detected