示例
serialize-error 7.0.1: serializeError
已验证示例 — npm serialize-error 7.0.1: serializeError. contract 在 node 22 · linux debian/x64 · docker 上运行并通过: serializeError serializes standard Error objects…
sha256:4d467b925034aeea905837250328c3a3210e6a8d998f4baf3c2ec1072d2d4d0b
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 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 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 serialize-error.serializeError in pkg:npm/serialize-error@7.0.1
- 符号
-
- serialize-error.serializeError
- 环境
- node 22.23.2
- 创建时间
- 2026-09-04T12:26:20Z
契约
- serializeError serializes standard Error objects into plain objects with name, message, and stack
- serializeError preserves custom properties and error codes
- serializeError serializes custom Error subclasses preserving their specific name
- serializeError handles nested error objects
- serializeError handles circular references without throwing
- serializeError passes through primitive values and null
- serializeError serializes plain objects preserving structure
- serializeError converts thrown functions to descriptive string representation and omits function properties
- serializeError handles arrays and errors contained within arrays
文件
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
源代码
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 serialize-error.serializeError in pkg:npm/serialize-error@7.0.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/serialize-error@7.0.1
Demonstrate these symbols/APIs:
- serialize-error.serializeError
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:89ced311d40f3ca90307384ec715142776053179b95c2199bb9d25c852984f7b","constraints":{"executionContext":"node"},"contract":["serializeError serializes standard Error objects into plain objects with name, message, and stack","serializeError preserves custom properties and error codes","serializeError serializes custom Error subclasses preserving their specific name","serializeError handles nested error objects","serializeError handles circular references without throwing","serializeError passes through primitive values and null","serializeError serializes plain objects preserving structure","serializeError converts thrown functions to descriptive string representation and omits function properties","serializeError handles arrays and errors contained within arrays"],"goal":"verify serialize-error.serializeError in pkg:npm/serialize-error@7.0.1","kind":"HOW","packages":["pkg:npm/serialize-error@7.0.1"],"schemaVersion":1,"symbols":["serialize-error.serializeError"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","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/serialize-error@7.0.1"],"schemaVersion":1,"subject":"pkg:npm/serialize-error@7.0.1","symbols":["serialize-error.serializeError"],"verifierAdapter":"node-typescript@1"}
import { serializeError, deserializeError } from 'serialize-error';
export { serializeError, deserializeError };
{
"name": "sample-serialize-error-serialize-error",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-serialize-error-serialize-error",
"version": "1.0.0",
"dependencies": {
"serialize-error": "7.0.1"
}
},
"node_modules/serialize-error": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-7.0.1.tgz",
"integrity": "sha512-8I8TjW5KMOKsZQTvoxjuSIa7foAwPWGOts+6o7sgjz41/qMD9VQHEDxi6PBvK2l0MXUmqZyNpUK+T2tQaaElvw==",
"license": "MIT",
"dependencies": {
"type-fest": "^0.13.1"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/type-fest": {
"version": "0.13.1",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz",
"integrity": "sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==",
"license": "(MIT OR CC0-1.0)",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
}
}
}
{
"name": "sample-serialize-error-serialize-error",
"version": "1.0.0",
"type": "module",
"private": true,
"dependencies": {
"serialize-error": "7.0.1"
}
}
{
"schemaVersion": 1,
"goal": "verify serialize-error.serializeError in pkg:npm/serialize-error@7.0.1",
"kind": "HOW",
"packages": [
"pkg:npm/serialize-error@7.0.1"
],
"symbols": [
"serialize-error.serializeError"
]
}
import assert from 'node:assert/strict';
import { serializeError } from 'serialize-error';
// 1. serializeError serializes standard Error objects into plain objects with name, message, and stack
{
const err = new Error('standard error message');
const serialized = serializeError(err);
assert.equal(typeof serialized, 'object');
assert.equal(serialized.name, 'Error');
assert.equal(serialized.message, 'standard error message');
assert.equal(typeof serialized.stack, 'string');
assert.ok(serialized.stack.includes('standard error message'));
const json = JSON.stringify(serialized);
assert.ok(json.includes('"name":"Error"'));
assert.ok(json.includes('"message":"standard error message"'));
}
// 2. serializeError preserves custom properties and error codes
{
const err = new Error('failed operation');
err.code = 'ERR_OPERATION_FAILED';
err.statusCode = 500;
err.details = { retryable: false };
const serialized = serializeError(err);
assert.equal(serialized.code, 'ERR_OPERATION_FAILED');
assert.equal(serialized.statusCode, 500);
assert.deepEqual(serialized.details, { retryable: false });
}
// 3. serializeError serializes custom Error subclasses preserving their specific name
{
const typeErr = new TypeError('invalid argument type');
const serializedType = serializeError(typeErr);
assert.equal(serializedType.name, 'TypeError');
assert.equal(serializedType.message, 'invalid argument type');
class CustomAppError extends Error {
constructor(msg) {
super(msg);
this.name = 'CustomAppError';
}
}
const customErr = new CustomAppError('custom application error');
const serializedCustom = serializeError(customErr);
assert.equal(serializedCustom.name, 'CustomAppError');
assert.equal(serializedCustom.message, 'custom application error');
}
// 4. serializeError handles nested error objects
{
const parent = new Error('parent error occurred');
parent.cause = new Error('root cause failure');
const serialized = serializeError(parent);
assert.equal(serialized.name, 'Error');
assert.equal(serialized.message, 'parent error occurred');
assert.equal(typeof serialized.cause, 'object');
assert.equal(serialized.cause.name, 'Error');
assert.equal(serialized.cause.message, 'root cause failure');
assert.equal(typeof serialized.cause.stack, 'string');
}
// 5. serializeError handles circular references without throwing
{
const err = new Error('circular error');
err.self = err;
const serialized = serializeError(err);
assert.equal(serialized.name, 'Error');
assert.equal(serialized.self, '[Circular]');
const a = new Error('cycle A');
const b = new Error('cycle B');
a.sibling = b;
b.sibling = a;
const serializedA = serializeError(a);
assert.equal(serializedA.sibling.name, 'Error');
assert.equal(serializedA.sibling.sibling, '[Circular]');
}
// 6. serializeError passes through primitive values and null
{
assert.equal(serializeError('plain string error'), 'plain string error');
assert.equal(serializeError(404), 404);
assert.equal(serializeError(true), true);
assert.equal(serializeError(false), false);
assert.equal(serializeError(null), null);
assert.equal(serializeError(undefined), undefined);
}
// 7. serializeError serializes plain objects preserving structure
{
const plain = {
message: 'plain error-like object',
code: 'CUSTOM_CODE',
nested: { count: 42 }
};
const serialized = serializeError(plain);
assert.deepEqual(serialized, {
message: 'plain error-like object',
code: 'CUSTOM_CODE',
nested: { count: 42 }
});
}
// 8. serializeError converts thrown functions to descriptive string representation and omits function properties
{
function sampleHandler() {}
assert.equal(serializeError(sampleHandler), '[Function: sampleHandler]');
assert.equal(serializeError(() => {}), '[Function: anonymous]');
const err = new Error('error with method');
err.action = () => {};
const serialized = serializeError(err);
assert.equal(serialized.action, undefined);
}
// 9. serializeError handles arrays and errors contained within arrays
{
const err = new Error('batch validation failure');
err.errors = [
'field required',
new RangeError('value out of bounds')
];
const serialized = serializeError(err);
assert.ok(Array.isArray(serialized.errors));
assert.equal(serialized.errors[0], 'field required');
assert.equal(serialized.errors[1].name, 'RangeError');
assert.equal(serialized.errors[1].message, 'value out of bounds');
}
原始种子者
匿名