{"ScriptPreparationCode":"var arr = [{\r\n de: {\r\n product: {\r\n \u0027test.a.label\u0027: \u0027Beispiel A\u0027,\r\n \u0027test.a.body\u0027: \u0027Blindtext A\u0027,\r\n },\r\n override: {\r\n \u0027test.a.override\u0027: \u0027\u00DCberschrieben A\u0027,\r\n },\r\n },\r\n en: {\r\n product: {\r\n \u0027test.a.label\u0027: \u0027Example A\u0027,\r\n \u0027test.a.body\u0027: \u0027Lorem Ipsum A\u0027,\r\n },\r\n override: {\r\n \u0027test.a.override\u0027: \u0027Override A\u0027,\r\n },\r\n },\r\n}, {\r\n de: {\r\n product: {\r\n \u0027test.b.label\u0027: \u0027Beispiel B\u0027,\r\n \u0027test.b.body\u0027: \u0027Blindtext B\u0027,\r\n },\r\n override: {\r\n \u0027test.b.override\u0027: \u0027\u00DCberschrieben B\u0027,\r\n },\r\n },\r\n en: {\r\n product: {\r\n \u0027test.b.label\u0027: \u0027Example B\u0027,\r\n \u0027test.b.body\u0027: \u0027Lorem Ipsum B\u0027,\r\n },\r\n override: {\r\n \u0027test.b.override\u0027: \u0027Override B\u0027,\r\n },\r\n },\r\n}, {\r\n de: {\r\n product: {\r\n \u0027test.single-language.label\u0027: \u0027Beispiel einzelne Sprache\u0027,\r\n \u0027test.single-language.body\u0027: \u0027Blindtext f\u00FCr einzelene Sprache\u0027,\r\n },\r\n override: {\r\n \u0027test.single-language.override\u0027: \u0027\u00DCberschrieben einzelene Sprache\u0027,\r\n },\r\n },\r\n}, {\r\n de: {\r\n product: {\r\n \u0027test.single-namespace.label\u0027: \u0027Beispiel Single Namespace\u0027,\r\n },\r\n },\r\n en: {\r\n product: {\r\n \u0027test.single-namespace.label\u0027: \u0027Example Single Namespace\u0027,\r\n },\r\n },\r\n}, {}, {\r\n de: {},\r\n en: {},\r\n}];\r\n\r\nfunction deepMerge(obj1, obj2) {\r\n for (const key of Object.keys(obj2)) {\r\n if (obj2[key] instanceof Object \u0026\u0026 obj1[key] instanceof Object) {\r\n obj1[key] = deepMerge(obj1[key], obj2[key]);\r\n } else {\r\n obj1[key] = obj2[key];\r\n }\r\n }\r\n\r\n return obj1;\r\n}\r\n\r\nfunction deepMergeWithSpread(obj1, obj2) {\r\n const result = {\r\n ...obj1\r\n };\r\n\r\n for (const key of Object.keys(obj2)) {\r\n if (obj2[key] instanceof Object \u0026\u0026 obj1[key] instanceof Object) {\r\n result[key] = deepMergeWithSpread(obj1[key], obj2[key]);\r\n } else {\r\n result[key] = obj2[key];\r\n }\r\n }\r\n\r\n return result;\r\n}\r\n\r\nfunction mergeLocalizedAndNamespacedTranslationRecord(target, source) {\r\n const result = {\r\n ...target\r\n };\r\n Object.keys(source).forEach((locale) =\u003E {\r\n if (!(locale in target)) {\r\n result[locale] = source[locale];\r\n } else {\r\n result[locale] = mergeNamespacedTranslationRecords(target[locale], source[locale]);\r\n }\r\n });\r\n\r\n return result;\r\n}\r\n\r\nfunction mergeNamespacedTranslationRecords(target, source) {\r\n const result = {\r\n ...target\r\n };\r\n Object.keys(source).forEach((namespace) =\u003E {\r\n if (!(namespace in target)) {\r\n result[namespace] = source[namespace];\r\n } else {\r\n result[namespace] = mergeSimpleRecords(target[namespace], source[namespace]);\r\n }\r\n });\r\n\r\n return result;\r\n}\r\n\r\nfunction mergeSimpleRecords(target, source) {\r\n const result = {\r\n ...target\r\n };\r\n Object.keys(source).forEach((key) =\u003E {\r\n result[key] = source[key];\r\n });\r\n\r\n return result;\r\n}","TestCases":[{"Name":"deepMerge","Code":"deepMerge(arr[0], arr[1]);","IsDeferred":false},{"Name":"deepMergeWithSpread","Code":"deepMergeWithSpread(arr[0], arr[1]);","IsDeferred":false},{"Name":"Library deepmerge","Code":"deepmerge(arr[0], arr[1]);","IsDeferred":false},{"Name":"mergeLocalizedAndNamespacedTranslationRecord","Code":"mergeLocalizedAndNamespacedTranslationRecord(arr[0], arr[1]);","IsDeferred":false}]}