MCPcopy
hub / github.com/formatjs/formatjs / getPathValue

Function getPathValue

tools/generate-cldr-locales.ts:38–45  ·  view source on GitHub ↗
(value: unknown, path: string)

Source from the content-addressed store, hash-verified

36}
37
38function getPathValue(value: unknown, path: string): unknown {
39 return path.split('.').reduce((current, segment) => {
40 if (current && typeof current === 'object' && segment in current) {
41 return (current as Record<string, unknown>)[segment]
42 }
43 throw new Error(`Unable to resolve JSON path "${path}"`)
44 }, value)
45}
46
47function getLocalesFromFiles(files: string[]): string[] {
48 return files.map(file => file.split(/[\\/]/)[0]).filter(isCanonicalLocale)

Callers 1

getLocalesFromJsonFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected