/**
* Binds arguments from configuration files with default values.
*
* @param {object} configFiles An object where keys are config file names and values are the config data.
* @param {object} defaultValues An object containing default values for each configurable parameter.
* @returns {object} A merged configuration object with values from config files overriding defaults.
*/
function bindConfigArguments(configFiles, defaultValues) {
const config = { ...defaultValues }; // Start with default values
for (const fileName in configFiles) {
if (configFiles.hasOwnProperty(fileName)) {
const fileConfig = configFiles[fileName];
// Check if the file config is an object
if (typeof fileConfig === 'object' && fileConfig !== null) {
for (const key in fileConfig) {
if (fileConfig.hasOwnProperty(key)) {
config[key] = fileConfig[key]; // Override default with file config
}
}
}
}
}
return config;
}
Add your comment