MCPcopy Index your code
hub / github.com/angular/angular / getCaseIndex

Function getCaseIndex

packages/core/src/render3/i18n/i18n_apply.ts:582–601  ·  view source on GitHub ↗

* Returns the index of the current case of an ICU expression depending on the main binding value * * @param icuExpression * @param bindingValue The value of the main binding used by this ICU expression

(icuExpression: TIcu, bindingValue: string)

Source from the content-addressed store, hash-verified

580 * @param bindingValue The value of the main binding used by this ICU expression
581 */
582function getCaseIndex(icuExpression: TIcu, bindingValue: string): number | null {
583 let index = icuExpression.cases.indexOf(bindingValue);
584 if (index === -1) {
585 switch (icuExpression.type) {
586 case IcuType.plural: {
587 const resolvedCase = getPluralCase(bindingValue, getLocaleId());
588 index = icuExpression.cases.indexOf(resolvedCase);
589 if (index === -1 && resolvedCase !== 'other') {
590 index = icuExpression.cases.indexOf('other');
591 }
592 break;
593 }
594 case IcuType.select: {
595 index = icuExpression.cases.indexOf('other');
596 break;
597 }
598 }
599 }
600 return index === -1 ? null : index;
601}

Callers 1

applyIcuSwitchCaseFunction · 0.85

Calls 3

getPluralCaseFunction · 0.90
getLocaleIdFunction · 0.90
indexOfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…