MCPcopy
hub / github.com/formatjs/formatjs / pruneLocation

Function pruneLocation

packages/icu-messageformat-parser/index.ts:18–37  ·  view source on GitHub ↗
(els: MessageFormatElement[])

Source from the content-addressed store, hash-verified

16} from '#packages/icu-messageformat-parser/types.js'
17
18function pruneLocation(els: MessageFormatElement[]): void {
19 els.forEach(el => {
20 delete el.location
21 if (isSelectElement(el) || isPluralElement(el)) {
22 for (const k in el.options) {
23 delete el.options[k].location
24 pruneLocation(el.options[k].value)
25 }
26 } else if (isNumberElement(el) && isNumberSkeleton(el.style)) {
27 delete el.style.location
28 } else if (
29 (isDateElement(el) || isTimeElement(el)) &&
30 isDateTimeSkeleton(el.style)
31 ) {
32 delete el.style.location
33 } else if (isTagElement(el)) {
34 pruneLocation(el.children)
35 }
36 })
37}
38
39export function parse(
40 message: string,

Callers 1

parseFunction · 0.85

Calls 8

isSelectElementFunction · 0.85
isPluralElementFunction · 0.85
isNumberElementFunction · 0.85
isNumberSkeletonFunction · 0.85
isDateElementFunction · 0.85
isTimeElementFunction · 0.85
isDateTimeSkeletonFunction · 0.85
isTagElementFunction · 0.85

Tested by

no test coverage detected