MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / hookCalledInLoop

Function hookCalledInLoop

packages/hosts/mcp/src/create-artifact.ts:186–196  ·  view source on GitHub ↗
(code: string)

Source from the content-addressed store, hash-verified

184
185/** The first hook called inside any loop body, or `undefined`. */
186const hookCalledInLoop = (code: string): string | undefined => {
187 const scannable = withLiteralsBlanked(code);
188 for (const match of scannable.matchAll(LOOP_HEAD)) {
189 const keyword = match[1] ?? "";
190 if (keyword === "do" && !startsStatement(scannable, match.index)) continue;
191 const body = loopBody(scannable, keyword, match.index + match[0].length);
192 const hook = body === null ? undefined : HOOK_CALL.exec(body)?.[1];
193 if (hook) return hook;
194 }
195 return undefined;
196};
197
198/** Hooks whose in-loop use is almost always hand-rolled cursor pagination. */
199const PAGINATION_HOOKS = new Set(["useQuery", "useInfiniteQuery", "useSuspenseQuery"]);

Callers 1

validateArtifactCodeFunction · 0.85

Calls 4

withLiteralsBlankedFunction · 0.85
startsStatementFunction · 0.85
loopBodyFunction · 0.85
execMethod · 0.80

Tested by

no test coverage detected