MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / readStringAt

Function readStringAt

src/resolution/frameworks/expo-router.ts:239–282  ·  view source on GitHub ↗
(s: string, at: number)

Source from the content-addressed store, hash-verified

237 * with every `${…}` replaced by {@link HOLE}. Null when `at` is not a string.
238 */
239export function readStringAt(s: string, at: number): string | null {
240 const q = s[at];
241 if (q === '"' || q === "'") {
242 let out = '';
243 for (let i = at + 1; i < s.length; i++) {
244 const ch = s[i]!;
245 if (ch === '\\') {
246 out += s[i + 1] ?? '';
247 i++;
248 continue;
249 }
250 if (ch === q) return out;
251 out += ch;
252 }
253 return null;
254 }
255 if (q === '`') {
256 const end = skipTemplate(s, at);
257 let out = '';
258 for (let i = at + 1; i < end; i++) {
259 const ch = s[i]!;
260 if (ch === '\\') {
261 out += s[i + 1] ?? '';
262 i++;
263 continue;
264 }
265 if (ch === '$' && s[i + 1] === '{') {
266 let depth = 0;
267 for (i = i + 1; i < end; i++) {
268 if (s[i] === '{') depth++;
269 else if (s[i] === '}') {
270 depth--;
271 if (depth === 0) break;
272 }
273 }
274 out += HOLE;
275 continue;
276 }
277 out += ch;
278 }
279 return out;
280 }
281 return null;
282}
283
284export interface HrefLiteral {
285 /** The path part, `${…}` holes kept as {@link HOLE}; query and hash removed. */

Callers 15

leadingStringFunction · 0.90
baseUrlInFunction · 0.90
svelteKitLinkEdgesFunction · 0.90
screensInBodyFunction · 0.90
tanstackLinkEdgesFunction · 0.90
vueRouterLinkEdgesFunction · 0.90
nextLinkEdgesFunction · 0.90
staticStringFunction · 0.90
visitFunction · 0.90
routeNameInExpressionFunction · 0.90
parseVuePathObjectFunction · 0.90
parseTanstackRoutesFunction · 0.90

Calls 1

skipTemplateFunction · 0.85

Tested by

no test coverage detected