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

Function initializerAt

src/resolution/frameworks/react.ts:1786–1801  ·  view source on GitHub ↗
(body: string, at: number)

Source from the content-addressed store, hash-verified

1784
1785/** Where a declarator's initializer starts, past its `: Type` and `=`; -1 when it has none. */
1786export function initializerAt(body: string, at: number): number {
1787 for (let i = at; i < body.length; i++) {
1788 const ch = body[i]!;
1789 if (ch === '"' || ch === "'" || ch === '`') {
1790 i = skipString(body, i);
1791 if (i < 0) return -1;
1792 } else if (ch === '{' || ch === '(' || ch === '[') {
1793 i = matchBracket(body, i);
1794 if (i < 0) return -1;
1795 } else if (ch === '=') {
1796 if (body[i + 1] === '>' || body[i + 1] === '=') i++;
1797 else return i + 1;
1798 } else if (ch === ';' || ch === ',' || ch === '}' || ch === ')') return -1;
1799 }
1800 return -1;
1801}
1802
1803/**
1804 * Where the statement or declarator from `from` ends: at a `;`, a closing

Callers 6

initializerOfFunction · 0.90
valueLoaderFunction · 0.85
heldBindingFunction · 0.85
handedComponentFunction · 0.85
wrappedComponentNameFunction · 0.85
declareFunction · 0.85

Calls 2

skipStringFunction · 0.90
matchBracketFunction · 0.90

Tested by

no test coverage detected