MCPcopy Index your code
hub / github.com/formatjs/formatjs / processData

Function processData

packages/intl-localematcher/abstract/utils.ts:56–105  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

54let PROCESSED_DATA: LanguageInfo | undefined
55
56function processData(): LanguageInfo {
57 if (!PROCESSED_DATA) {
58 const paradigmLocales = jsonData.supplemental.languageMatching[
59 'written-new'
60 ][0]?.paradigmLocales?._locales.split(' ') as any
61 const matchVariables = jsonData.supplemental.languageMatching[
62 'written-new'
63 ].slice(1, 5) as any[]
64 const data = jsonData.supplemental.languageMatching['written-new'].slice(5)
65 const matches = data.map(d => {
66 const key = Object.keys(d)[0] as string
67 const value = (
68 d as Record<
69 string,
70 {
71 _desired: string
72 _distance: string
73 oneway?: string
74 }
75 >
76 )[key]
77 return {
78 supported: key,
79 desired: value._desired,
80 distance: +value._distance,
81 oneway: value.oneway === 'true' ? true : false,
82 }
83 }, {})
84 PROCESSED_DATA = {
85 matches,
86 matchVariables: matchVariables.reduce<Record<string, string[]>>(
87 (all, d) => {
88 const key = Object.keys(d)[0] as string
89 const value = d[key]
90 all[key.slice(1)] = value._value.split('+')
91 return all
92 },
93 {}
94 ),
95 paradigmLocales: [
96 ...paradigmLocales,
97 ...paradigmLocales.map((l: string) =>
98 new Intl.Locale(l.replace(/_/g, '-')).maximize().toString()
99 ),
100 ],
101 }
102 }
103
104 return PROCESSED_DATA
105}
106
107function isMatched(
108 locale: LSR,

Callers 1

findMatchingDistanceImplFunction · 0.85

Calls 2

maximizeMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected