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

Function extractKeys

packages/cli-lib/verify/checkMissingKeys.ts:9–16  ·  view source on GitHub ↗

* Flatten nested obj into list of keys, delimited by `.` * @param obj * @param parentKey * @returns

(obj: any, parentKey = '')

Source from the content-addressed store, hash-verified

7 * @returns
8 */
9function extractKeys(obj: any, parentKey = ''): string[] {
10 if (!obj || typeof obj !== 'object' || Array.isArray(obj)) {
11 return []
12 }
13 return Object.keys(obj)
14 .map(k => [parentKey ? `${parentKey}.${k}` : k, ...extractKeys(obj[k], k)])
15 .flat()
16}
17
18export async function checkMissingKeys(
19 translationFilesContents: Record<string, any>,

Callers 1

checkMissingKeysFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected