MCPcopy Create free account
hub / github.com/api-platform/website / sortJsonRecursive

Function sortJsonRecursive

pwa/update-i18n.ts:73–85  ·  view source on GitHub ↗
(data: Data)

Source from the content-addressed store, hash-verified

71
72 // Trie le fichier JSON par ordre alphabétique de manière récursive
73 const sortJsonRecursive = (data: Data): Data => {
74 const sortedData: Data = {};
75 Object.keys(data)
76 .sort()
77 .forEach((key) => {
78 if (typeof data[key] === "object") {
79 sortedData[key] = sortJsonRecursive(data[key]);
80 } else {
81 sortedData[key] = data[key];
82 }
83 });
84 return sortedData;
85 };
86
87 // Nom du fichier JSON à trier
88 const filePath = path.join(process.cwd(), fileToSort);

Callers 1

sortJsonFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected