1. /**
  2. * Binds arguments from configuration files with default values.
  3. *
  4. * @param {object} configFiles An object where keys are config file names and values are the config data.
  5. * @param {object} defaultValues An object containing default values for each configurable parameter.
  6. * @returns {object} A merged configuration object with values from config files overriding defaults.
  7. */
  8. function bindConfigArguments(configFiles, defaultValues) {
  9. const config = { ...defaultValues }; // Start with default values
  10. for (const fileName in configFiles) {
  11. if (configFiles.hasOwnProperty(fileName)) {
  12. const fileConfig = configFiles[fileName];
  13. // Check if the file config is an object
  14. if (typeof fileConfig === 'object' && fileConfig !== null) {
  15. for (const key in fileConfig) {
  16. if (fileConfig.hasOwnProperty(key)) {
  17. config[key] = fileConfig[key]; // Override default with file config
  18. }
  19. }
  20. }
  21. }
  22. }
  23. return config;
  24. }

Add your comment