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

Function edgeLabel

ui/src/lib/screens-model.ts:263–276  ·  view source on GitHub ↗
(links: ReadonlyArray<{ when: string; sites?: ReadonlyArray<{ when: string }> }>)

Source from the content-addressed store, hash-verified

261 * apart, and the full text is a hover away.
262 */
263export function edgeLabel(links: ReadonlyArray<{ when: string; sites?: ReadonlyArray<{ when: string }> }>): string {
264 // A link with several call sites is several scenarios: count them as ways.
265 const ways = links.flatMap((l) => (l.sites && l.sites.length > 1 ? l.sites.map((s) => s.when) : [l.when]));
266 if (ways.length === 1) {
267 const when = ways[0]!;
268 if (!when) return '';
269 const parts = clauses(when);
270 const last = clauseWords(parts[parts.length - 1] ?? when);
271 const text = parts.length > 1 ? `…${last}` : last;
272 return text.length > EDGE_LABEL_MAX ? `${text.slice(0, EDGE_LABEL_MAX - 1)}…` : text;
273 }
274 const conditional = ways.filter((w) => w).length;
275 return conditional > 0 ? `${ways.length} ways · ${conditional} conditional` : `${ways.length} ways`;
276}
277
278/* ---------------------------------------------------------------- build -- */
279

Callers 3

buildStepsModelFunction · 0.90
buildScreensModelFunction · 0.85

Calls 3

clausesFunction · 0.90
clauseWordsFunction · 0.90
mapMethod · 0.80

Tested by

no test coverage detected