docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
A utility that merges configuration objects from multiple sources into a single configuration object, supporting deep nested properties.
You need to implement a configuration merger that combines default configurations with user-provided overrides. The system should handle deeply nested configuration objects and support multiple configuration sources with proper precedence (later sources override earlier ones).
Your implementation must:
Given a default config { port: 3000, host: 'localhost' } and user config { port: 8080 }, merging produces { port: 8080, host: 'localhost' } @test
Given a default config with nested objects { server: { port: 3000, host: 'localhost' }, cache: { enabled: false } } and override { server: { port: 8080 }, cache: { enabled: true, ttl: 300 } }, merging produces { server: { port: 8080, host: 'localhost' }, cache: { enabled: true, ttl: 300 } } @test
Given three configs: { a: 1, b: { c: 2 } }, { b: { d: 3 }, e: 4 }, and { a: 5, b: { c: 6 } }, merging produces { a: 5, b: { c: 6, d: 3 }, e: 4 } @test
The original default and override configuration objects must not be modified after merging @test
/**
* Merges multiple configuration objects with deep nesting support
* @param {Object} defaultConfig - The default configuration object
* @param {...Object} overrides - One or more override configuration objects
* @returns {Object} A new merged configuration object
*/
function mergeConfig(defaultConfig, ...overrides);
module.exports = { mergeConfig };Provides deep object merging functionality.