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

Function subjectOf

src/ui-server/api/program.ts:399–408  ·  view source on GitHub ↗

* What every arm of a switch is deciding on: the longest start they share, cut * at a word. '' when they share nothing — then the head says nothing and each * arm says its own condition, which is never wrong.

(arms: readonly string[])

Source from the content-addressed store, hash-verified

397 * arm says its own condition, which is never wrong.
398 */
399function subjectOf(arms: readonly string[]): string {
400 if (arms.length < 2) return '';
401 let common = arms[0]!;
402 for (const arm of arms.slice(1)) {
403 let i = 0;
404 while (i < common.length && i < arm.length && common[i] === arm[i]) i++;
405 common = common.slice(0, i);
406 }
407 return /^[\w$.?[\]'"]+/.exec(common.trim())?.[0] ?? '';
408}
409
410/** Whether the last thing a block does is answer the request. */
411function repliesLast(input: ProgramInput, block: WireBlock): boolean {

Callers 1

sealFunction · 0.85

Calls 1

execMethod · 0.65

Tested by

no test coverage detected