MCPcopy Create free account
hub / github.com/angular/angular / getTIcu

Function getTIcu

packages/core/src/render3/i18n/i18n_util.ts:47–65  ·  view source on GitHub ↗
(tView: TView, index: number)

Source from the content-addressed store, hash-verified

45 * @param index Index where the value should be read from.
46 */
47export function getTIcu(tView: TView, index: number): TIcu | null {
48 const value = tView.data[index] as null | TIcu | TIcuContainerNode | string;
49 if (value === null || typeof value === 'string') return null;
50 if (
51 ngDevMode &&
52 !(Object.hasOwn(value, TVIEW) || Object.hasOwn(value, CURRENT_CASE_LVIEW_INDEX))
53 ) {
54 throwError("We expect to get 'null'|'TIcu'|'TIcuContainer', but got: " + value);
55 }
56 // Here the `Object.hasOwn(value, CURRENT_CASE_LVIEW_INDEX)` is a polymorphic read as it can be
57 // either TIcu or TIcuContainerNode. This is not ideal, but we still think it is OK because it
58 // will be just two cases which fits into the browser inline cache (inline cache can take up to
59 // 4)
60 const tIcu = Object.hasOwn(value, CURRENT_CASE_LVIEW_INDEX)
61 ? (value as TIcu)
62 : (value as TIcuContainerNode).value;
63 ngDevMode && assertTIcu(tIcu);
64 return tIcu;
65}
66
67/**
68 * Store `TIcu` at a give `index`.

Callers 5

i18n_parse_spec.tsFile · 0.90
i18n_spec.tsFile · 0.90
applyMutableOpCodesFunction · 0.90
applyUpdateOpCodesFunction · 0.90
applyIcuSwitchCaseRemoveFunction · 0.90

Calls 2

throwErrorFunction · 0.90
assertTIcuFunction · 0.90

Tested by

no test coverage detected