MCPcopy
hub / github.com/formatjs/formatjs / forEachLiteralElement

Function forEachLiteralElement

packages/cli-lib/pseudo_locale.ts:12–27  ·  view source on GitHub ↗
(
  ast: MessageFormatElement[],
  fn: (el: LiteralElement) => void
)

Source from the content-addressed store, hash-verified

10} from '@formatjs/icu-messageformat-parser'
11
12function forEachLiteralElement(
13 ast: MessageFormatElement[],
14 fn: (el: LiteralElement) => void
15): void {
16 ast.forEach(el => {
17 if (isLiteralElement(el)) {
18 fn(el)
19 } else if (isPluralElement(el) || isSelectElement(el)) {
20 for (const opt of Object.values(el.options)) {
21 forEachLiteralElement(opt.value, fn)
22 }
23 } else if (isTagElement(el)) {
24 forEachLiteralElement(el.children, fn)
25 }
26 })
27}
28
29/** @internal */
30export function generateXXLS(

Callers 3

generateXXACFunction · 0.85
generateENXAFunction · 0.85
generateENXBFunction · 0.85

Calls 4

isLiteralElementFunction · 0.90
isPluralElementFunction · 0.90
isSelectElementFunction · 0.90
isTagElementFunction · 0.90

Tested by

no test coverage detected