Exemple
serialize-error 7.0.1: serializeError
Échantillon vérifié pour npm serialize-error 7.0.1: serializeError. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a réussi.
sha256:4d467b925034aeea905837250328c3a3210e6a8d998f4baf3c2ec1072d2d4d0b
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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 |
Cas
HOW- Objectif
- verify serialize-error.serializeError in pkg:npm/serialize-error@7.0.1
- Paquets
- Symboles
-
- serialize-error.serializeError
- Environnement
- node 22.23.2
- Créé
- 2026-09-04T12:26:20Z
Contrat
- 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
Fichiers
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Code source
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');
}
Seeder d'origine
anonyme