MCPcopy Create free account
hub / github.com/chhoumann/quickadd / countChoicesByName

Method countChoicesByName

src/main.ts:559–574  ·  view source on GitHub ↗

Count how many choices anywhere in the tree carry `name` (names aren't unique).

(
		name: string,
		choices: IChoice[] = this.settings.choices,
	)

Source from the content-addressed store, hash-verified

557
558 /** Count how many choices anywhere in the tree carry `name` (names aren't unique). */
559 private countChoicesByName(
560 name: string,
561 choices: IChoice[] = this.settings.choices,
562 ): number {
563 let count = 0;
564 for (const choice of choices) {
565 if (choice.name === name) count++;
566 if (choice.type === "Multi") {
567 count += this.countChoicesByName(
568 name,
569 (choice as IMultiChoice).choices,
570 );
571 }
572 }
573 return count;
574 }
575
576 /** Surface a Notice when a URI's `choice=<name>` is ambiguous, so an automation
577 * that ran the wrong (first-matching) choice is at least diagnosable. */

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected