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-3/

Data Structure Validator

Build a validation utility that compares actual data structures against expected schemas or reference values to verify correctness. The validator should support comparing complex nested objects and arrays, handling edge cases that standard equality operators cannot address.

Requirements

Your validator should:

  1. Compare complex nested objects and arrays recursively to verify they match expected structures
  2. Handle special numeric values correctly:
    • Treat NaN values as equal when both are NaN
    • Distinguish between positive zero (+0) and negative zero (-0)
  3. Support comparing Date objects by their timestamp values
  4. Handle regular expression objects by comparing their patterns and flags
  5. Work correctly with circular references (objects that reference themselves)

Implementation

@generates

API

/**
 * Validates that actual data matches expected data using deep equality.
 *
 * @param {any} actual - The actual value to validate
 * @param {any} expected - The expected value
 * @returns {boolean} true if values are deeply equal, false otherwise
 */
function validate(actual, expected) {
  // IMPLEMENTATION HERE
}

module.exports = { validate };

Test Cases

  • Validates nested objects with matching properties @test
  • Validates nested arrays with matching elements @test
  • Correctly identifies NaN as equal to NaN @test
  • Distinguishes between positive and negative zero @test
  • Compares Date objects by timestamp @test
  • Compares RegExp objects by pattern and flags @test

Dependencies { .dependencies }

deep-eql { .dependency }

Provides deep equality comparison support.

Install with Tessl CLI

npx tessl i tessl/npm-deep-eql

tile.json