MCPcopy Create free account
hub / github.com/chhoumann/quickadd / readStringLiteral

Function readStringLiteral

src/utils/userScriptSecrets.ts:161–188  ·  view source on GitHub ↗
(
	source: string,
	index: number,
)

Source from the content-addressed store, hash-verified

159}
160
161function readStringLiteral(
162 source: string,
163 index: number,
164): { value: string; end: number } | null {
165 const quote = source[index];
166 if (quote !== "\"" && quote !== "'" && quote !== "`") return null;
167
168 let value = "";
169 for (let current = index + 1; current < source.length; current++) {
170 const char = source[current];
171
172 if (char === "\\") {
173 const escaped = source[current + 1];
174 if (escaped === undefined) return null;
175 value += escaped;
176 current += 1;
177 continue;
178 }
179
180 if (char === quote) {
181 return { value, end: current + 1 };
182 }
183
184 value += char;
185 }
186
187 return null;
188}
189
190function readIdentifier(
191 source: string,

Callers 5

findMatchingDelimiterFunction · 0.85
collectStringConstantsFunction · 0.85
findOptionsObjectSpansFunction · 0.85
readOptionKeyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected