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

Function flat

ui/src/lib/steps-model.ts:877–893  ·  view source on GitHub ↗
(list: string[])

Source from the content-addressed store, hash-verified

875
876 /** The steps that fire nothing, side by side — a screen's handlers are siblings, not a hierarchy. */
877 const flat = (list: string[]): { pos: Map<string, { x: number; line: number }>; lines: number; width: number } => {
878 const pos = new Map<string, { x: number; line: number }>();
879 let line = 0;
880 let width = 0;
881 let lx = 0;
882 for (const id of list) {
883 const bw = widthOf(id);
884 if (lx > 0 && lx + bw > lineMax) {
885 line += 1;
886 lx = 0;
887 }
888 pos.set(id, { x: lx, line });
889 width = Math.max(width, lx + bw);
890 lx += bw + NODE_GAP;
891 }
892 return { pos, lines: list.length === 0 ? 0 : line + 1, width };
893 };
894
895 // The region's blocks, in the walk's order: everything that fires
896 // nothing first, as one spread, then a cluster per step that does.

Callers 1

layAtFunction · 0.85

Calls 2

widthOfFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected