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

Function inOrder

__tests__/ui-steps-api-servers.test.ts:288–310  ·  view source on GitHub ↗

* The `program` reading, one line per item, indented — the rail as a reader * meets it. A step prints its label, a fork its condition and each arm's, a * bracketed run its words.

(p: Awaited<ReturnType<typeof buildSteps>>)

Source from the content-addressed store, hash-verified

286 * bracketed run its words.
287 */
288function inOrder(p: Awaited<ReturnType<typeof buildSteps>>): string[] {
289 const label = (id: string) => p.steps.find((s) => s.id === id)?.label ?? id;
290 const out: string[] = [];
291 const walk = (block: WireBlock, indent: string): void => {
292 for (const item of block) {
293 if (item.kind === 'step') {
294 out.push(`${indent}${label(item.step)}${item.again ? ' (again)' : ''}`);
295 if (item.body) walk(item.body, `${indent} `);
296 } else if (item.kind === 'fork') {
297 out.push(`${indent}${item.form} ${item.on}`);
298 for (const arm of item.arms) {
299 out.push(`${indent} ${arm.when}${arm.ends ? ` → ${arm.ends}` : ''}`);
300 walk(arm.body, `${indent} `);
301 }
302 } else if (item.kind === 'block') {
303 out.push(`${indent}${item.block} ${item.via?.name ?? item.by ?? ''}`.trimEnd());
304 walk(item.body, `${indent} `);
305 } else out.push(`${indent}cut ${item.why}`);
306 }
307 };
308 if (p.program) walk(p.program.root, '');
309 return out;
310}
311
312describe('in the code’s order', () => {
313 it('reads an Express handler as it is written, helper and all', async () => {

Callers 1

Calls 1

walkFunction · 0.70

Tested by

no test coverage detected