1. /**
  2. * Deserializes configuration values with manual overrides.
  3. *
  4. * @param {object} config - The base configuration object.
  5. * @param {object} overrides - An object containing manual overrides for configuration values.
  6. * @returns {object} - The deserialized configuration object.
  7. */
  8. function deserializeConfig(config, overrides) {
  9. const deserialized = { ...config }; // Create a shallow copy to avoid modifying the original
  10. for (const key in overrides) {
  11. if (deserialized.hasOwnProperty(key)) {
  12. deserialized[key] = overrides[key]; // Override existing values
  13. }
  14. }
  15. return deserialized;
  16. }
  17. // Example usage (for testing)
  18. // const config = {
  19. // apiUrl: 'https://api.example.com',
  20. // timeout: 5000,
  21. // debug: false,
  22. // };
  23. // const overrides = {
  24. // apiUrl: 'https://dev.example.com',
  25. // timeout: 10000,
  26. // debug: true,
  27. // };
  28. // const deserializedConfig = deserializeConfig(config, overrides);
  29. // console.log(deserializedConfig);

Add your comment