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

Function parseWithinBudget

src/extraction/parse-budget.ts:18–23  ·  view source on GitHub ↗
(parser: Parser, source: string, budgetMs = REQUEST_PARSE_BUDGET_MS)

Source from the content-addressed store, hash-verified

16
17/** `parser.parse(source)`, or null when it runs past the budget. */
18export function parseWithinBudget(parser: Parser, source: string, budgetMs = REQUEST_PARSE_BUDGET_MS): Tree | null {
19 const deadline = Date.now() + budgetMs;
20 // The runtime hands the callback's return value to the parser: `true` cancels.
21 const cancel = (() => Date.now() > deadline) as unknown as () => void;
22 return parser.parse(source, null, { progressCallback: cancel }) ?? null;
23}

Callers 3

tokenizeRegionFunction · 0.90
parseFunction · 0.90
guardsForFileSyncFunction · 0.90

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected