示例
deep-eql 5.0.2: deepEql
已验证示例 — npm deep-eql 5.0.2: deepEql. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: deepEql returns true for identical primitives and false for…
sha256:c798aa8129374aed9e593915fa6d9085e12d17269dd9e9e19af7b3f5437b4c8b
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| 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 |
案例
HOW- 目标
- verify deepEql in pkg:npm/deep-eql@5.0.2
- 符号
-
- deepEql
- 环境
- node 22.23.2
- 创建时间
- 2026-08-26T10:43:56Z
契约
- 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
文件
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
源代码
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.
{"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"}
{
"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"
}
}
}
}
{
"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"
}
{
"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"
}
}
'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
};
'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.');
原始种子者
匿名