/**
* Deserializes configuration values with manual overrides.
*
* @param {object} config - The base configuration object.
* @param {object} overrides - An object containing manual overrides for configuration values.
* @returns {object} - The deserialized configuration object.
*/
function deserializeConfig(config, overrides) {
const deserialized = { ...config }; // Create a shallow copy to avoid modifying the original
for (const key in overrides) {
if (deserialized.hasOwnProperty(key)) {
deserialized[key] = overrides[key]; // Override existing values
}
}
return deserialized;
}
// Example usage (for testing)
// const config = {
// apiUrl: 'https://api.example.com',
// timeout: 5000,
// debug: false,
// };
// const overrides = {
// apiUrl: 'https://dev.example.com',
// timeout: 10000,
// debug: true,
// };
// const deserializedConfig = deserializeConfig(config, overrides);
// console.log(deserializedConfig);
Add your comment