fes.js/packages/fes-utils/src/mergeConfig.js
2022-03-26 20:24:14 +08:00

16 lines
442 B
JavaScript

export default function mergeConfig(defaultConfig, ...configs) {
const ret = { ...defaultConfig };
configs.forEach((config) => {
if (!config) return;
Object.keys(config).forEach((key) => {
const val = config[key];
if (typeof val === 'function') {
ret[key] = val(ret[key]);
} else {
ret[key] = val;
}
});
});
return ret;
}