MCPcopy
hub / github.com/formatjs/formatjs / getLocalesFromJson

Function getLocalesFromJson

tools/generate-cldr-locales.ts:51–60  ·  view source on GitHub ↗
(root: string, files: string[], jsonPath: string)

Source from the content-addressed store, hash-verified

49}
50
51function getLocalesFromJson(root: string, files: string[], jsonPath: string) {
52 return files.flatMap(file => {
53 const json = JSON.parse(readFileSync(join(root, file), 'utf8'))
54 const value = getPathValue(json, jsonPath)
55 if (!value || typeof value !== 'object' || Array.isArray(value)) {
56 throw new Error(`JSON path "${jsonPath}" must resolve to an object`)
57 }
58 return Object.keys(value).filter(isCanonicalLocale)
59 })
60}
61
62function formatLocales(variable: string, locales: string[]): string {
63 const lines = [

Callers 1

mainFunction · 0.85

Calls 2

getPathValueFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected