or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-6/

Configuration Manager

Build a configuration manager that merges user configuration with default settings, supporting nested configuration structures with proper overriding behavior.

Requirements

Your task is to implement a configuration manager that:

  1. Accepts a default configuration object and a user configuration object
  2. Merges them together so that user values override defaults at any nesting level
  3. Preserves nested structure - if both default and user configs have nested objects at the same key, those nested objects should be merged together
  4. Handles cases where a nested object in defaults is replaced by a primitive value in user config (or vice versa)
  5. Returns the merged configuration object

Implementation

@generates

API

/**
 * Merges user configuration with default configuration
 * @param {Object} defaultConfig - The default configuration object
 * @param {Object} userConfig - The user-provided configuration object
 * @returns {Object} A merged configuration object
 */
function mergeConfig(defaultConfig, userConfig);

module.exports = { mergeConfig };

Test Cases

  • Given default config {server: {host: "localhost", port: 3000}} and user config {server: {port: 8080}}, returns {server: {host: "localhost", port: 8080}} @test
  • Given default config {a: {b: {c: 1, d: 2}}} and user config {a: {b: {d: 3, e: 4}}}, returns {a: {b: {c: 1, d: 3, e: 4}}} @test
  • Given default config {feature: {enabled: true}} and user config {feature: false}, returns {feature: false} @test
  • Given default config {x: 1} and user config {y: {z: 2}}, returns {x: 1, y: {z: 2}} @test

Dependencies { .dependencies }

mixin-deep { .dependency }

Provides deep object merging functionality

@satisfied-by