示例
deep-eql 5.0.2
已验证示例 — npm deep-eql 5.0.2. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: deepEqual returns true for identical primitives and false for distinct…
sha256:d71bbf243ca68e5038a2bf5806b394836dbbe503038b8e8f9fed49ab3639a4d1
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 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 pkg:npm/deep-eql@5.0.2
- 环境
- node 22.23.2
- 创建时间
- 2026-08-26T08:58:24Z
契约
- deepEqual returns true for identical primitives and false for distinct primitives
- deepEqual treats NaN as equal to NaN and distinguishes +0 from -0
- deepEqual evaluates Date instances by their timestamps
- deepEqual evaluates RegExp instances by their source pattern and flags
- deepEqual evaluates Error instances by name, message, and code properties
- deepEqual evaluates nested arrays, sets, and maps recursively
- deepEqual evaluates nested objects regardless of key order and includes symbol properties
- deepEqual handles circular references without throwing stack overflow errors
- deepEqual supports custom comparator functions to override equality logic
文件
- 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 pkg:npm/deep-eql@5.0.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/deep-eql@5.0.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:44195a7faefa05a8dc53eba125344dc225498763dd90c5329bf54037fa70cf1d","contract":["deepEqual returns true for identical primitives and false for distinct primitives","deepEqual treats NaN as equal to NaN and distinguishes +0 from -0","deepEqual evaluates Date instances by their timestamps","deepEqual evaluates RegExp instances by their source pattern and flags","deepEqual evaluates Error instances by name, message, and code properties","deepEqual evaluates nested arrays, sets, and maps recursively","deepEqual evaluates nested objects regardless of key order and includes symbol properties","deepEqual handles circular references without throwing stack overflow errors","deepEqual supports custom comparator functions to override equality logic"],"goal":"verify pkg:npm/deep-eql@5.0.2","kind":"HOW","packages":["pkg:npm/deep-eql@5.0.2"],"schemaVersion":1},"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","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 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 pkg:npm/deep-eql@5.0.2",
"kind": "HOW",
"packages": [
"pkg:npm/deep-eql@5.0.2"
]
}
'use strict';
const deepEqlModule = require('deep-eql');
const deepEqual = 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 deepEqual(actual, expected, options);
}
module.exports = {
deepEqual,
isEqual,
MemoizeMap
};
'use strict';
const assert = require('assert');
const { deepEqual, isEqual, MemoizeMap } = require('../src/index');
// 1. Module export verification
{
assert.strictEqual(typeof deepEqual, 'function');
assert.strictEqual(typeof isEqual, 'function');
assert.strictEqual(typeof MemoizeMap, 'function');
}
// 2. deepEqual returns true for identical primitives and false for distinct primitives
{
assert.strictEqual(deepEqual(1, 1), true);
assert.strictEqual(deepEqual('hello', 'hello'), true);
assert.strictEqual(deepEqual(true, true), true);
assert.strictEqual(deepEqual(null, null), true);
assert.strictEqual(deepEqual(undefined, undefined), true);
assert.strictEqual(deepEqual(1, 2), false);
assert.strictEqual(deepEqual('a', 'b'), false);
assert.strictEqual(deepEqual(true, false), false);
assert.strictEqual(deepEqual(null, undefined), false);
}
// 3. deepEqual treats NaN as equal to NaN and distinguishes +0 from -0
{
assert.strictEqual(deepEqual(NaN, NaN), true);
assert.strictEqual(isEqual(NaN, NaN), true);
assert.strictEqual(deepEqual([NaN], [NaN]), true);
assert.strictEqual(deepEqual({ val: NaN }, { val: NaN }), true);
assert.strictEqual(deepEqual(0, 0), true);
assert.strictEqual(deepEqual(-0, -0), true);
assert.strictEqual(deepEqual(0, -0), false);
assert.strictEqual(deepEqual(-0, 0), false);
assert.strictEqual(deepEqual([0], [-0]), false);
assert.strictEqual(deepEqual({ n: 0 }, { n: -0 }), false);
}
// 4. deepEqual evaluates Date instances by their timestamps
{
const d1 = new Date(1700000000000);
const d2 = new Date(1700000000000);
const d3 = new Date(1700000000001);
assert.strictEqual(deepEqual(d1, d2), true);
assert.strictEqual(deepEqual(d1, d3), false);
}
// 5. deepEqual 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(deepEqual(r1, r2), true);
assert.strictEqual(deepEqual(r1, r3), false);
assert.strictEqual(deepEqual(r1, r4), false);
}
// 6. deepEqual evaluates Error instances by name, message, and code 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(deepEqual(e1, e2), true);
assert.strictEqual(deepEqual(e1, e3), false);
assert.strictEqual(deepEqual(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(deepEqual(eCode1, eCode2), true);
assert.strictEqual(deepEqual(eCode1, eCode3), false);
const eExtra1 = Object.assign(new Error('err'), { otherProp: 1 });
const eExtra2 = Object.assign(new Error('err'), { otherProp: 2 });
assert.strictEqual(deepEqual(eExtra1, eExtra2), true);
}
// 7. deepEqual evaluates nested arrays, sets, and maps recursively
{
assert.strictEqual(deepEqual([1, [2, [3]]], [1, [2, [3]]]), true);
assert.strictEqual(deepEqual([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(deepEqual(set1, set2), true);
assert.strictEqual(deepEqual(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(deepEqual(map1, map2), true);
assert.strictEqual(deepEqual(map1, map3), false);
}
// 8. deepEqual evaluates nested objects regardless of key order and includes symbol properties
{
assert.strictEqual(deepEqual({ a: 1, b: 2 }, { b: 2, a: 1 }), true);
assert.strictEqual(
deepEqual({ nested: { x: 10, y: 20 } }, { nested: { y: 20, x: 10 } }),
true
);
assert.strictEqual(deepEqual({ 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(deepEqual(objSym1, objSym2), true);
assert.strictEqual(deepEqual(objSym1, objSym3), false);
}
// 9. deepEqual 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(deepEqual(circA, circB), true);
assert.strictEqual(deepEqual(circA, circC), false);
}
// 10. deepEqual 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(
deepEqual({ val: 1.01 }, { val: 1.03 }, { comparator: customComparator }),
true
);
assert.strictEqual(
deepEqual({ val: 1.01 }, { val: 1.20 }, { comparator: customComparator }),
false
);
}
console.log('All deep-eql contract tests passed.');
原始种子者
匿名