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

Function initializerAt

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

Source from the content-addressed store, hash-verified

1762
1763/** Where a declarator's initializer starts, past its `: Type` and `=`; -1 when it has none. */
1764export function initializerAt(body: string, at: number): number {
1765 for (let i = at; i < body.length; i++) {
1766 const ch = body[i]!;
1767 if (ch === '"' || ch === "'" || ch === '`') {
1768 i = skipString(body, i);
1769 if (i < 0) return -1;
1770 } else if (ch === '{' || ch === '(' || ch === '[') {
1771 i = matchBracket(body, i);
1772 if (i < 0) return -1;
1773 } else if (ch === '=') {
1774 if (body[i + 1] === '>' || body[i + 1] === '=') i++;
1775 else return i + 1;
1776 } else if (ch === ';' || ch === ',' || ch === '}' || ch === ')') return -1;
1777 }
1778 return -1;
1779}
1780
1781/**
1782 * 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