- private static isObject(item): boolean {
- return item && typeof item === 'object' && !Array.isArray(item);
- }
-
- private static deepMerge(target: object, ...sources: object[]): object {
- if (!sources.length) {
- return target;
- }
- const source = sources.shift();
-
- if (Configuration.isObject(target) && Configuration.isObject(source)) {
- for (const key in source) {
- if (Configuration.isObject(source[key])) {
- if (!target[key]) {
- Object.assign(target, { [key]: {} });
- }
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
- Configuration.deepMerge(target[key], source[key]);
- } else {
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
- Object.assign(target, { [key]: source[key] });
- }
- }
- }
- return Configuration.deepMerge(target, ...sources);
- }
-