or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-8/

Configuration Merger

A utility that merges configuration objects from multiple sources into a single configuration object, supporting deep nested properties.

Problem Description

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).

Requirements

Your implementation must:

  1. Accept a default configuration object as the first parameter
  2. Accept one or more override configuration objects as additional parameters
  3. Return a new merged configuration object without modifying the original inputs
  4. Support deep merging of nested configuration properties
  5. Handle conflicting properties by giving precedence to later configuration sources
  6. Preserve all properties from nested objects that aren't explicitly overridden

Test Cases

  • 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

Implementation

@generates

API

/**
 * 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 };

Dependencies { .dependencies }

mixin-deep { .dependency }

Provides deep object merging functionality.

@satisfied-by