docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
Build a utility function that merges multiple configuration objects with varying availability into a single cohesive configuration. The system should handle cases where some configuration sources might be unavailable or undefined while preserving valid configuration data.
Your task is to implement a configuration merger that:
The merger should be resilient to sparse inputs (where some configuration sources may be undefined or null) and ensure that only valid configuration data is included in the final result.
{ api: { key: 'test' } }, undefined, and another config { api: { timeout: 5000 } } produces { api: { key: 'test', timeout: 5000 } } @test{ server: { port: 3000 } }, third is undefined results in { server: { port: 3000 } } @test{ db: { host: 'localhost' } }, undefined, and { db: { port: 5432 } } produces { db: { host: 'localhost', port: 5432 } } @test/**
* Merges multiple configuration objects into a single configuration.
* Handles undefined or null configuration sources gracefully.
*
* @param {...Object} configs - Configuration objects to merge
* @returns {Object} The merged configuration object
*/
function mergeConfigs(...configs) {
// Implementation here
}
module.exports = { mergeConfigs };Provides deep object merging functionality.