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

Function topLevelObjects

src/resolution/frameworks/object-literal.ts:59–75  ·  view source on GitHub ↗
(s: string, from: number, to: number)

Source from the content-addressed store, hash-verified

57
58/** Each `{…}` written directly in `[from, to)`, as its own extent. */
59export function* topLevelObjects(s: string, from: number, to: number): Generator<{ start: number; end: number }> {
60 for (let i = from; i < to; i++) {
61 const ch = s[i]!;
62 if (ch === '"' || ch === "'" || ch === '`') {
63 const end = skipString(s, i);
64 if (end < 0) return;
65 i = end;
66 continue;
67 }
68 if (ch === '{') {
69 const end = matchBracket(s, i);
70 if (end < 0) return;
71 yield { start: i, end };
72 i = end;
73 }
74 }
75}
76
77/** An object's own fields — key to its value text and where the key sits. Nested structures are stepped over. */
78export function readFields(s: string, start: number, end: number): Map<string, { text: string; at: number }> {

Callers 3

walkFunction · 0.90
visitFunction · 0.90
parseVueRoutesFunction · 0.90

Calls 2

matchBracketFunction · 0.85
skipStringFunction · 0.70

Tested by

no test coverage detected