CodeSampleX

Sample

deep-eql 5.0.2: deepEql

Verified sample for npm deep-eql 5.0.2: deepEql. The contract ran on node 22 · linux alpine/x64 · docker and passed: deepEql returns true for identical…

sha256:c798aa8129374aed9e593915fa6d9085e12d17269dd9e9e19af7b3f5437b4c8b

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Verification-run environments

Environment Contract Stages Run
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-26

Case

HOW
Goal
verify deepEql in pkg:npm/deep-eql@5.0.2
Packages
Symbols
  • deepEql
Environment
node 22.23.2
Created
2026-08-26T10:43:56Z

Contract

  1. deepEql returns true for identical primitives and false for distinct primitives
  2. deepEql treats NaN as equal to NaN and distinguishes +0 from -0
  3. deepEql evaluates Date instances by their timestamps
  4. deepEql evaluates RegExp instances by their source pattern and flags
  5. deepEql evaluates Error instances by name, message, and custom properties
  6. deepEql evaluates nested arrays, sets, and maps recursively
  7. deepEql evaluates nested objects regardless of key order and includes symbol properties
  8. deepEql handles circular references without throwing stack overflow errors
  9. deepEql supports custom comparator functions to override equality logic
  10. deepEql supports custom memoize maps via MemoizeMap

Files

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.js

Download the source artifact (tar.gz)

Source

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify deepEql in pkg:npm/deep-eql@5.0.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/deep-eql@5.0.2
Demonstrate these symbols/APIs:
  - deepEql
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:f59f113f1aaba6e2c6f9b9461aea5134457c0655597f44af503b2039acc60777","constraints":{"executionContext":"node"},"contract":["deepEql returns true for identical primitives and false for distinct primitives","deepEql treats NaN as equal to NaN and distinguishes +0 from -0","deepEql evaluates Date instances by their timestamps","deepEql evaluates RegExp instances by their source pattern and flags","deepEql evaluates Error instances by name, message, and custom properties","deepEql evaluates nested arrays, sets, and maps recursively","deepEql evaluates nested objects regardless of key order and includes symbol properties","deepEql handles circular references without throwing stack overflow errors","deepEql supports custom comparator functions to override equality logic","deepEql supports custom memoize maps via MemoizeMap"],"goal":"verify deepEql in pkg:npm/deep-eql@5.0.2","kind":"HOW","packages":["pkg:npm/deep-eql@5.0.2"],"schemaVersion":1,"symbols":["deepEql"]},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/deep-eql@5.0.2"],"schemaVersion":1,"subject":"pkg:npm/deep-eql@5.0.2","symbols":["deepEql"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-deep-eql",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-deep-eql",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "deep-eql": "5.0.2"
      }
    },
    "node_modules/deep-eql": {
      "version": "5.0.2",
      "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz",
      "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==",
      "license": "MIT",
      "engines": {
        "node": ">=6"
      }
    }
  }
}
package.json
{
  "name": "sample-deep-eql",
  "version": "1.0.0",
  "description": "verify deepEql in pkg:npm/deep-eql@5.0.2",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "deep-eql": "5.0.2"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify deepEql in pkg:npm/deep-eql@5.0.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/deep-eql@5.0.2"
  ],
  "symbols": [
    "deepEql"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
'use strict';

const deepEqlModule = require('deep-eql');
const deepEql = deepEqlModule.default || deepEqlModule;
const { MemoizeMap } = deepEqlModule;

/**
 * Compare two values for deep equality according to the deep-eql algorithm.
 *
 * @param {*} actual - The value to test.
 * @param {*} expected - The expected value.
 * @param {Object} [options] - Optional comparison options (e.g. comparator, memoize).
 * @returns {boolean} True if values are deeply equal, false otherwise.
 */
function isEqual(actual, expected, options) {
  return deepEql(actual, expected, options);
}

module.exports = {
  deepEql,
  isEqual,
  MemoizeMap
};
test/contract.js
'use strict';

const assert = require('assert');
const { deepEql, isEqual, MemoizeMap } = require('../src/index');

// 1. Module export verification
{
  assert.strictEqual(typeof deepEql, 'function');
  assert.strictEqual(typeof isEqual, 'function');
  assert.strictEqual(typeof MemoizeMap, 'function');
}

// 2. deepEql returns true for identical primitives and false for distinct primitives
{
  assert.strictEqual(deepEql(1, 1), true);
  assert.strictEqual(deepEql('hello', 'hello'), true);
  assert.strictEqual(deepEql(true, true), true);
  assert.strictEqual(deepEql(null, null), true);
  assert.strictEqual(deepEql(undefined, undefined), true);
  assert.strictEqual(deepEql(1, 2), false);
  assert.strictEqual(deepEql('a', 'b'), false);
  assert.strictEqual(deepEql(true, false), false);
  assert.strictEqual(deepEql(null, undefined), false);
}

// 3. deepEql treats NaN as equal to NaN and distinguishes +0 from -0
{
  assert.strictEqual(deepEql(NaN, NaN), true);
  assert.strictEqual(isEqual(NaN, NaN), true);
  assert.strictEqual(deepEql([NaN], [NaN]), true);
  assert.strictEqual(deepEql({ val: NaN }, { val: NaN }), true);

  assert.strictEqual(deepEql(0, 0), true);
  assert.strictEqual(deepEql(-0, -0), true);
  assert.strictEqual(deepEql(0, -0), false);
  assert.strictEqual(deepEql(-0, 0), false);
  assert.strictEqual(deepEql([0], [-0]), false);
  assert.strictEqual(deepEql({ n: 0 }, { n: -0 }), false);
}

// 4. deepEql evaluates Date instances by their timestamps
{
  const d1 = new Date(1700000000000);
  const d2 = new Date(1700000000000);
  const d3 = new Date(1700000000001);
  assert.strictEqual(deepEql(d1, d2), true);
  assert.strictEqual(deepEql(d1, d3), false);
}

// 5. deepEql evaluates RegExp instances by their source pattern and flags
{
  const r1 = /abc/gi;
  const r2 = /abc/gi;
  const r3 = /abc/g;
  const r4 = /def/gi;
  assert.strictEqual(deepEql(r1, r2), true);
  assert.strictEqual(deepEql(r1, r3), false);
  assert.strictEqual(deepEql(r1, r4), false);
}

// 6. deepEql evaluates Error instances by name, message, and custom properties
{
  const e1 = new Error('something failed');
  const e2 = new Error('something failed');
  const e3 = new Error('different message');
  const te = new TypeError('something failed');

  assert.strictEqual(deepEql(e1, e2), true);
  assert.strictEqual(deepEql(e1, e3), false);
  assert.strictEqual(deepEql(e1, te), false);

  const eCode1 = Object.assign(new Error('err'), { code: 'ERR_CUSTOM' });
  const eCode2 = Object.assign(new Error('err'), { code: 'ERR_CUSTOM' });
  const eCode3 = Object.assign(new Error('err'), { code: 'ERR_OTHER' });
  assert.strictEqual(deepEql(eCode1, eCode2), true);
  assert.strictEqual(deepEql(eCode1, eCode3), false);
}

// 7. deepEql evaluates nested arrays, sets, and maps recursively
{
  assert.strictEqual(deepEql([1, [2, [3]]], [1, [2, [3]]]), true);
  assert.strictEqual(deepEql([1, 2, 3], [1, 2, 4]), false);

  const set1 = new Set(['a', 'b', 3]);
  const set2 = new Set(['b', 'a', 3]);
  const set3 = new Set(['a', 'b', 4]);
  assert.strictEqual(deepEql(set1, set2), true);
  assert.strictEqual(deepEql(set1, set3), false);

  const map1 = new Map([['k1', { x: 1 }], ['k2', { y: 2 }]]);
  const map2 = new Map([['k1', { x: 1 }], ['k2', { y: 2 }]]);
  const map3 = new Map([['k1', { x: 1 }], ['k2', { y: 99 }]]);
  assert.strictEqual(deepEql(map1, map2), true);
  assert.strictEqual(deepEql(map1, map3), false);
}

// 8. deepEql evaluates nested objects regardless of key order and includes symbol properties
{
  assert.strictEqual(deepEql({ a: 1, b: 2 }, { b: 2, a: 1 }), true);
  assert.strictEqual(
    deepEql({ nested: { x: 10, y: 20 } }, { nested: { y: 20, x: 10 } }),
    true
  );
  assert.strictEqual(deepEql({ a: 1, b: 2 }, { a: 1, b: 3 }), false);

  const sym = Symbol('test');
  const objSym1 = { [sym]: 'val', normal: 1 };
  const objSym2 = { [sym]: 'val', normal: 1 };
  const objSym3 = { [sym]: 'other', normal: 1 };
  assert.strictEqual(deepEql(objSym1, objSym2), true);
  assert.strictEqual(deepEql(objSym1, objSym3), false);
}

// 9. deepEql handles circular references without throwing stack overflow errors
{
  const circA = { val: 1 };
  circA.self = circA;

  const circB = { val: 1 };
  circB.self = circB;

  const circC = { val: 2 };
  circC.self = circC;

  assert.strictEqual(deepEql(circA, circB), true);
  assert.strictEqual(deepEql(circA, circC), false);
}

// 10. deepEql supports custom comparator functions to override equality logic
{
  const customComparator = (a, b) => {
    if (typeof a === 'number' && typeof b === 'number') {
      return Math.abs(a - b) < 0.05;
    }
    return null;
  };

  assert.strictEqual(
    deepEql({ val: 1.01 }, { val: 1.03 }, { comparator: customComparator }),
    true
  );
  assert.strictEqual(
    deepEql({ val: 1.01 }, { val: 1.20 }, { comparator: customComparator }),
    false
  );
}

// 11. deepEql supports custom memoize maps via MemoizeMap
{
  const memoizeMap = new MemoizeMap();
  const objA = { deep: { prop: 'hello' } };
  const objB = { deep: { prop: 'hello' } };

  assert.strictEqual(deepEql(objA, objB, { memoize: memoizeMap }), true);
}

console.log('All deepEql contract tests passed.');

Origin Seeder

anonymous