( by: "name" | "id", targetPropertyValue: string, choices: IChoice[] = this.settings.choices, )
| 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( |
no outgoing calls
no test coverage detected