docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
Build a configuration management system that safely combines default settings with user-provided overrides without modifying the original configuration objects.
Your task is to implement a configuration manager that:
The system should work with configuration objects that can have multiple levels of nesting, and later configurations should override earlier ones at the primitive value level while preserving nested object structures.
/**
* Creates a merged configuration from defaults and user overrides
* @param {Object} defaults - The default configuration object
* @param {Object} userConfig - User-provided configuration overrides
* @returns {Object} A new merged configuration object
*/
function createConfig(defaults, userConfig);
/**
* Merges multiple configuration sources into a single configuration
* @param {...Object} configs - Multiple configuration objects to merge
* @returns {Object} A new merged configuration object
*/
function mergeConfigs(...configs);defaults = { api: { timeout: 5000 } } and overrides = { api: { retries: 3 } }, calling createConfig(defaults, overrides) returns a new object { api: { timeout: 5000, retries: 3 } } and the defaults object remains unchanged @test{ server: { port: 3000, ssl: { enabled: false } } } and user config { server: { ssl: { enabled: true, cert: 'path/to/cert' } } }, the merged config contains { server: { port: 3000, ssl: { enabled: true, cert: 'path/to/cert' } } } @testconfig1 = { a: 1, b: 2 }, config2 = { b: 3, c: 4 }, and config3 = { a: 5, d: 6 }, calling mergeConfigs(config1, config2, config3) returns { a: 5, b: 3, c: 4, d: 6 } and all input configs remain unchanged @test{ database: { host: 'localhost', port: 5432 } } with user config { database: { port: 3306 } }, both the original default and user config objects are unmodified @testProvides deep object merging capabilities.