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

Method getChoice

src/main.ts:534–556  ·  view source on GitHub ↗
(
		by: "name" | "id",
		targetPropertyValue: string,
		choices: IChoice[] = this.settings.choices,
	)

Source from the content-addressed store, hash-verified

532 }
533
534 private getChoice(
535 by: "name" | "id",
536 targetPropertyValue: string,
537 choices: IChoice[] = this.settings.choices,
538 ): IChoice | null {
539 for (const choice of choices) {
540 if (choice[by] === targetPropertyValue) {
541 return choice;
542 }
543 if (choice.type === "Multi") {
544 const subChoice = this.getChoice(
545 by,
546 targetPropertyValue,
547 (choice as IMultiChoice).choices,
548 );
549 if (subChoice) {
550 return subChoice;
551 }
552 }
553 }
554
555 return null;
556 }
557
558 /** Count how many choices anywhere in the tree carry `name` (names aren't unique). */
559 private countChoicesByName(

Callers 4

onloadMethod · 0.95
runUriChoiceLegacyMethod · 0.95
getChoiceByIdMethod · 0.95
getChoiceByNameMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected