github
1349 of 1526 branches covered (88.4%)
Branch coverage included in aggregate %.
12 of 849 new or added lines in 21 files covered. (1.41%)
10 existing lines in 1 file now uncovered.5324 of 9354 relevant lines covered (56.92%)
32.18 hits per line
1 |
export abstract class ConfigBase<C extends Record<string, any>> { |
× |
NEW
|
protected abstract privateKeys: (keyof C)[];
|
× |
NEW
|
|
× |
4 |
protected value: Required<C>;
|
× |
5 |
|
× |
6 |
protected defaultConfig() {
|
× |
7 |
return {} as Required<C>;
|
× |
8 |
} |
× |
9 |
|
× |
10 |
constructor() { |
× |
11 |
this.value = this.defaultConfig(); |
× |
12 |
} |
× |
13 |
|
× |
14 |
public mergeConfig = (userCfg: C): Required<C> => {
|
× |
NEW
|
const excludePrivate = Object.entries(userCfg).reduce((acc, [key, val]) => {
|
× |
NEW
|
if (this.privateKeys.includes(key)) return acc; |
× |
NEW
|
acc[key as keyof C] = val; |
× |
NEW
|
return acc;
|
× |
NEW
|
}, {} as C); |
× |
20 |
this.value = {
|
× |
21 |
...this.defaultConfig(),
|
× |
NEW
|
...excludePrivate, |
× |
23 |
}; |
× |
24 |
return this.value; |
× |
25 |
}; |
× |
26 |
|
× |
27 |
get() { |
× |
28 |
return this.value; |
× |
29 |
} |
× |
NEW
|
|
× |
NEW
|
set<T extends keyof C>(key: T, val: C[T]) { |
× |
NEW
|
this.value[key] = val;
|
× |
NEW
|
} |
× |
34 |
} |
× |