CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-deep-eql

Improved deep equality testing for Node.js and the browser with support for complex types and circular references.

Overall
score

96%

Overview
Eval results
Files

task.mdevals/scenario-7/

Configuration Comparator

Build a utility that compares configuration objects to determine if they are deeply equal.

Requirements

Create a module that exports a compareConfigs function which:

  1. Takes two parameters: config1 and config2 (both plain objects)
  2. Returns a boolean indicating whether the configurations are deeply equal

The function should correctly handle:

  • Nested objects of arbitrary depth
  • Objects with properties in different orders (should be considered equal if values match)
  • Empty objects
  • Plain objects with multiple levels of nesting

Test Cases

  • Comparing {port: 3000, host: "localhost"} with {port: 3000, host: "localhost"} returns true @test
  • Comparing {port: 3000, host: "localhost"} with {host: "localhost", port: 3000} returns true @test
  • Comparing {server: {port: 3000}} with {server: {port: 8080}} returns false @test
  • Comparing {} with {} returns true @test

Implementation

@generates

API

/**
 * Compares two configuration objects for deep equality.
 *
 * @param {Object} config1 - The first configuration object
 * @param {Object} config2 - The second configuration object
 * @returns {boolean} True if configurations are deeply equal, false otherwise
 */
function compareConfigs(config1, config2) {
  // Implementation here
}

module.exports = { compareConfigs };

Dependencies { .dependencies }

deep-eql { .dependency }

Provides deep equality comparison for configuration objects.

Install with Tessl CLI

npx tessl i tessl/npm-deep-eql

tile.json