Skip to content

Commit

Permalink
🔀 Merge pull request #1547 from jovotech/v4/dev
Browse files Browse the repository at this point in the history
🔖 Prepare latest release
  • Loading branch information
jankoenig authored Apr 26, 2023
2 parents dba408f + 89f2090 commit caf996f
Show file tree
Hide file tree
Showing 10 changed files with 26,461 additions and 4,502 deletions.
17 changes: 14 additions & 3 deletions common/src/Configurable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _merge from 'lodash.merge';
import _mergeWith from 'lodash.mergewith';
import { AnyObject, DeepPartial } from '.';

export abstract class Configurable<CONFIG extends AnyObject = AnyObject> {
Expand All @@ -8,11 +8,22 @@ export abstract class Configurable<CONFIG extends AnyObject = AnyObject> {
constructor(config?: DeepPartial<CONFIG>) {
this.initConfig = config;
const defaultConfig = this.getDefaultConfig();
this.config = config ? _merge(defaultConfig, config) : defaultConfig;

this.config = config
? _mergeWith(defaultConfig, config, (objValue, srcValue) => {
if (Array.isArray(objValue)) {
return srcValue;
}
})
: defaultConfig;
}

mergeConfig(config?: DeepPartial<CONFIG>): void {
this.config = _merge(this.config, config);
this.config = _mergeWith(this.config, config, (objValue, srcValue) => {
if (Array.isArray(objValue)) {
return srcValue;
}
});
}

get name(): string {
Expand Down
Loading

0 comments on commit caf996f

Please sign in to comment.