MCPcopy Index your code
hub / github.com/itwanger/toBeBetterJavaer / findRouteArray

Function findRouteArray

scripts/sync-sidebar.js:374–387  ·  view source on GitHub ↗
(source, route)

Source from the content-addressed store, hash-verified

372}
373
374function findRouteArray(source, route) {
375 const routePattern = new RegExp(`(["'])${escapeRegExp(route)}\\1\\s*:\\s*\\[`);
376 const match = routePattern.exec(source);
377 if (!match) {
378 return null;
379 }
380
381 const arrayStart = match.index + match[0].lastIndexOf("[");
382 const arrayEnd = findMatchingBracket(source, arrayStart);
383 if (arrayEnd === -1) {
384 throw new Error(`Could not parse route array: ${route}`);
385 }
386 return { start: arrayStart, end: arrayEnd };
387}
388
389function findMatchingBracket(source, openIndex) {
390 let depth = 0;

Callers 1

syncTargetFunction · 0.85

Calls 2

escapeRegExpFunction · 0.85
findMatchingBracketFunction · 0.85

Tested by

no test coverage detected