CodeSampleX

Пример

deep-eql 5.0.2: default

Проверенный пример — npm deep-eql 5.0.2: default. Контракт выполнен на node 22 · linux debian/x64 · docker и пройден: deepEqual compares primitive values…

sha256:c74d54b420b327059153841f50924a0b7f4b9f6b5514f8b3d878061c87b993df

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. MIT-0

Свидетельства выполнения

Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.

Основа свидетельства
Подписанный контракт пройден
Квитанции проверки
1
Ключи подписи, собравшие его
1
Заявленная среда node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Среды запусков проверки

Окружение Контракт Этапы Запуск
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-04

Кейс

HOW
Цель
verify deep-eql.default in pkg:npm/deep-eql@5.0.2
Пакеты
Символы
  • deep-eql.default
Окружение
node 22.23.2
Создан
2026-09-04T00:03:19Z

Контракт

  1. deepEqual compares primitive values according to Object.is semantics where NaN equals NaN and +0 does not equal -0
  2. deepEqual compares boxed primitives by primitive valueOf without equating them to raw primitives
  3. deepEqual compares Date instances by their numeric timestamp value
  4. deepEqual compares RegExp instances by their string representation including pattern and flags
  5. deepEqual compares Error objects by name, message, and code properties regardless of enumerability or non-standard properties
  6. deepEqual compares flat iterable objects including Arrays and TypedArrays recursively
  7. deepEqual compares Sets and Maps by entry equality regardless of insertion order
  8. deepEqual compares plain objects by own and inherited enumerable keys and symbol properties recursively
  9. deepEqual handles circular references without infinite recursion using MemoizeMap
  10. deepEqual supports custom comparator callback in options to override equality checks and fallback to default logic on null

Файлы

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

Скачать артефакт с исходным кодом (tar.gz)

Исходный код

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 deep-eql.default 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:
  - deep-eql.default

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:da880897132a6550526f708ce3c944e65716a53db106f1c2e1e11e2a6c40be8c","contract":["deepEqual compares primitive values according to Object.is semantics where NaN equals NaN and +0 does not equal -0","deepEqual compares boxed primitives by primitive valueOf without equating them to raw primitives","deepEqual compares Date instances by their numeric timestamp value","deepEqual compares RegExp instances by their string representation including pattern and flags","deepEqual compares Error objects by name, message, and code properties regardless of enumerability or non-standard properties","deepEqual compares flat iterable objects including Arrays and TypedArrays recursively","deepEqual compares Sets and Maps by entry equality regardless of insertion order","deepEqual compares plain objects by own and inherited enumerable keys and symbol properties recursively","deepEqual handles circular references without infinite recursion using MemoizeMap","deepEqual supports custom comparator callback in options to override equality checks and fallback to default logic on null"],"goal":"verify deep-eql.default in pkg:npm/deep-eql@5.0.2","kind":"HOW","packages":["pkg:npm/deep-eql@5.0.2"],"schemaVersion":1,"symbols":["deep-eql.default"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","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":["deep-eql.default"],"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",
  "type": "module",
  "private": true,
  "license": "MIT-0",
  "dependencies": {
    "deep-eql": "5.0.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify deep-eql.default in pkg:npm/deep-eql@5.0.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/deep-eql@5.0.2"
  ],
  "symbols": [
    "deep-eql.default"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import deepEqual, { MemoizeMap } from 'deep-eql';

// Contract 1: deepEqual compares primitive values according to Object.is semantics where NaN equals NaN and +0 does not equal -0
{
  assert.strictEqual(deepEqual(1, 1), true);
  assert.strictEqual(deepEqual(1, 2), false);
  assert.strictEqual(deepEqual('hello', 'hello'), true);
  assert.strictEqual(deepEqual('hello', 'world'), false);
  assert.strictEqual(deepEqual(true, true), true);
  assert.strictEqual(deepEqual(true, false), false);
  assert.strictEqual(deepEqual(null, null), true);
  assert.strictEqual(deepEqual(undefined, undefined), true);
  assert.strictEqual(deepEqual(null, undefined), false);
  assert.strictEqual(deepEqual(NaN, NaN), true);
  assert.strictEqual(deepEqual(+0, -0), false);
  assert.strictEqual(deepEqual(0, 0), true);
}

// Contract 2: deepEqual compares boxed primitives by primitive valueOf without equating them to raw primitives
{
  assert.strictEqual(deepEqual(new String('test'), new String('test')), true);
  assert.strictEqual(deepEqual(new String('test'), new String('other')), false);
  assert.strictEqual(deepEqual(new String('test'), 'test'), false);
  assert.strictEqual(deepEqual(new Number(42), new Number(42)), true);
  assert.strictEqual(deepEqual(new Number(42), new Number(99)), false);
  assert.strictEqual(deepEqual(new Number(42), 42), false);
  assert.strictEqual(deepEqual(new Boolean(true), new Boolean(true)), true);
  assert.strictEqual(deepEqual(new Boolean(true), new Boolean(false)), false);
  assert.strictEqual(deepEqual(new Boolean(true), true), false);
}

// Contract 3: deepEqual compares Date instances by their numeric timestamp value
{
  const d1 = new Date('2026-01-01T00:00:00.000Z');
  const d2 = new Date('2026-01-01T00:00:00.000Z');
  const d3 = new Date('2026-01-02T00:00:00.000Z');
  assert.strictEqual(deepEqual(d1, d2), true);
  assert.strictEqual(deepEqual(d1, d3), false);
}

// Contract 4: deepEqual compares RegExp instances by their string representation including pattern and flags
{
  assert.strictEqual(deepEqual(/abc/g, /abc/g), true);
  assert.strictEqual(deepEqual(/abc/g, /abc/i), false);
  assert.strictEqual(deepEqual(/abc/g, /xyz/g), false);
}

// Contract 5: deepEqual compares Error objects by name, message, and code properties regardless of enumerability or non-standard properties
{
  const err1 = new Error('test message');
  const err2 = new Error('test message');
  assert.strictEqual(deepEqual(err1, err2), true);

  const typeErr = new TypeError('test message');
  assert.strictEqual(deepEqual(err1, typeErr), false);

  const codeErr1 = Object.assign(new Error('failure'), { code: 'ERR_TIMEOUT' });
  const codeErr2 = Object.assign(new Error('failure'), { code: 'ERR_TIMEOUT' });
  const codeErr3 = Object.assign(new Error('failure'), { code: 'ERR_CANCEL' });
  assert.strictEqual(deepEqual(codeErr1, codeErr2), true);
  assert.strictEqual(deepEqual(codeErr1, codeErr3), false);

  // Non-standard properties outside name, message, code are ignored on Errors
  const extraPropErr1 = Object.assign(new Error('same'), { ignoredProp: 'valA' });
  const extraPropErr2 = Object.assign(new Error('same'), { ignoredProp: 'valB' });
  assert.strictEqual(deepEqual(extraPropErr1, extraPropErr2), true);
}

// Contract 6: deepEqual compares flat iterable objects including Arrays and TypedArrays recursively
{
  assert.strictEqual(deepEqual([1, [2, 3]], [1, [2, 3]]), true);
  assert.strictEqual(deepEqual([1, [2, 3]], [1, [2, 4]]), false);
  assert.strictEqual(deepEqual([1, 2], [1, 2, 3]), false);
  assert.strictEqual(deepEqual(new Uint8Array([1, 2, 3]), new Uint8Array([1, 2, 3])), true);
  assert.strictEqual(deepEqual(new Uint8Array([1, 2, 3]), new Uint8Array([1, 2, 4])), false);
  assert.strictEqual(deepEqual(new Int32Array([10, 20]), new Int32Array([10, 20])), true);
}

// Contract 7: deepEqual compares Sets and Maps by entry equality regardless of insertion order
{
  const setA = new Set(['foo', 'bar', 'baz']);
  const setB = new Set(['baz', 'bar', 'foo']);
  const setC = new Set(['foo', 'bar']);
  assert.strictEqual(deepEqual(setA, setB), true);
  assert.strictEqual(deepEqual(setA, setC), false);

  const mapA = new Map([['k1', 'v1'], ['k2', 'v2']]);
  const mapB = new Map([['k2', 'v2'], ['k1', 'v1']]);
  const mapC = new Map([['k1', 'v1'], ['k2', 'diff']]);
  assert.strictEqual(deepEqual(mapA, mapB), true);
  assert.strictEqual(deepEqual(mapA, mapC), false);
}

// Contract 8: deepEqual compares plain objects by own and inherited enumerable keys and symbol properties recursively
{
  const symKey = Symbol('contract-symbol');
  const obj1 = { a: 1, b: { nested: 'val' }, [symKey]: true };
  const obj2 = { a: 1, b: { nested: 'val' }, [symKey]: true };
  const obj3 = { a: 1, b: { nested: 'other' }, [symKey]: true };
  assert.strictEqual(deepEqual(obj1, obj2), true);
  assert.strictEqual(deepEqual(obj1, obj3), false);

  // Inherited enumerable properties
  const proto1 = Object.create({ inheritedKey: 'shared' });
  proto1.ownKey = 100;
  const proto2 = Object.create({ inheritedKey: 'shared' });
  proto2.ownKey = 100;
  const proto3 = Object.create({ inheritedKey: 'different' });
  proto3.ownKey = 100;
  assert.strictEqual(deepEqual(proto1, proto2), true);
  assert.strictEqual(deepEqual(proto1, proto3), false);
}

// Contract 9: deepEqual handles circular references without infinite recursion using MemoizeMap
{
  const circA = { name: 'circular' };
  circA.self = circA;
  const circB = { name: 'circular' };
  circB.self = circB;
  assert.strictEqual(deepEqual(circA, circB), true);

  const customMemoize = new MemoizeMap();
  assert.strictEqual(deepEqual(circA, circB, { memoize: customMemoize }), true);
}

// Contract 10: deepEqual supports custom comparator callback in options to override equality checks and fallback to default logic on null
{
  const caseInsensitiveComparator = (left, right) => {
    if (typeof left === 'string' && typeof right === 'string') {
      return left.toLowerCase() === right.toLowerCase();
    }
    return null; // Fall back to default comparison logic
  };

  // Custom comparison applied to strings
  assert.strictEqual(deepEqual('TEST', 'test', { comparator: caseInsensitiveComparator }), true);
  assert.strictEqual(deepEqual({ text: 'HELLO' }, { text: 'hello' }, { comparator: caseInsensitiveComparator }), true);

  // Fallback to default comparison for non-strings
  assert.strictEqual(deepEqual({ count: 5 }, { count: 5 }, { comparator: caseInsensitiveComparator }), true);
  assert.strictEqual(deepEqual({ count: 5 }, { count: 10 }, { comparator: caseInsensitiveComparator }), false);
}

console.log('All deep-eql contract tests passed.');

Исходный сидер

аноним