Ejemplo
safe-stable-stringify 2.5.0: configure
Muestra verificada para npm safe-stable-stringify 2.5.0: configure. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó.
sha256:747bf30351d648b805b3ddb3271daa17be275b7679d792fc61deebad576368fc
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-21 |
Caso
HOW- Objetivo
- verify safe-stable-stringify.configure in pkg:npm/safe-stable-stringify@2.5.0
- Paquetes
- Símbolos
-
- safe-stable-stringify.configure
- Entorno
- node 22.23.2
- Creado
- 2026-08-21T04:31:12Z
Contrato
- Calling safe-stable-stringify.configure returns a custom stringify function tailored with the specified options.
- Setting circularValue to a custom string replaces circular references with that string during serialization.
- Setting circularValue to TypeError causes serialization to throw a TypeError when a circular reference is encountered.
- Setting circularValue to undefined omits circular properties from the serialized JSON output.
- Setting deterministic to false preserves object property insertion order instead of sorting keys alphabetically.
- Setting bigint to true serializes BigInt values as numbers, while bigint: false omits BigInt properties.
- Setting maximumDepth limits nested serialization depth, replacing deeper objects with '[Object]' and arrays with '[Array]'.
- Setting maximumBreadth limits the number of serialized properties per object and appends a truncation summary.
- Setting strict to true throws an Error when encountering non-JSON-serializable values such as functions or NaN.
Archivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.js
Código fuente
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 safe-stable-stringify.configure in pkg:npm/safe-stable-stringify@2.5.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/safe-stable-stringify@2.5.0
Demonstrate these symbols/APIs:
- safe-stable-stringify.configure
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:df2874c6b142aabc6fa60aa909f07fcaf20de1e87de85cfbd26ee4bf2fecaec4","constraints":{"executionContext":"node"},"contract":["Calling safe-stable-stringify.configure returns a custom stringify function tailored with the specified options.","Setting circularValue to a custom string replaces circular references with that string during serialization.","Setting circularValue to TypeError causes serialization to throw a TypeError when a circular reference is encountered.","Setting circularValue to undefined omits circular properties from the serialized JSON output.","Setting deterministic to false preserves object property insertion order instead of sorting keys alphabetically.","Setting bigint to true serializes BigInt values as numbers, while bigint: false omits BigInt properties.","Setting maximumDepth limits nested serialization depth, replacing deeper objects with '[Object]' and arrays with '[Array]'.","Setting maximumBreadth limits the number of serialized properties per object and appends a truncation summary.","Setting strict to true throws an Error when encountering non-JSON-serializable values such as functions or NaN."],"goal":"verify safe-stable-stringify.configure in pkg:npm/safe-stable-stringify@2.5.0","kind":"HOW","packages":["pkg:npm/safe-stable-stringify@2.5.0"],"schemaVersion":1,"symbols":["safe-stable-stringify.configure"]},"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/safe-stable-stringify@2.5.0"],"schemaVersion":1,"subject":"pkg:npm/safe-stable-stringify@2.5.0","symbols":["safe-stable-stringify.configure"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-safe-stable-stringify",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-safe-stable-stringify",
"version": "1.0.0",
"dependencies": {
"safe-stable-stringify": "2.5.0"
}
},
"node_modules/safe-stable-stringify": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz",
"integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==",
"license": "MIT",
"engines": {
"node": ">=10"
}
}
}
}
{
"name": "sample-safe-stable-stringify",
"version": "1.0.0",
"private": true,
"description": "verify safe-stable-stringify.configure in pkg:npm/safe-stable-stringify@2.5.0",
"dependencies": {
"safe-stable-stringify": "2.5.0"
}
}
{
"schemaVersion": 1,
"goal": "verify safe-stable-stringify.configure in pkg:npm/safe-stable-stringify@2.5.0",
"kind": "HOW",
"packages": [
"pkg:npm/safe-stable-stringify@2.5.0"
],
"symbols": [
"safe-stable-stringify.configure"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
const assert = require('node:assert');
const { configure, stringify: defaultStringify } = require('safe-stable-stringify');
// 1. Default stringify behavior (deterministic key sorting and default circular marker)
{
const obj = { z: 1, a: 2, m: 3 };
assert.strictEqual(defaultStringify(obj), '{"a":2,"m":3,"z":1}');
const circ = { name: 'root' };
circ.self = circ;
assert.strictEqual(defaultStringify(circ), '{"name":"root","self":"[Circular]"}');
}
// 2. Custom circularValue string replaces circular references with that string
{
const customCircStringify = configure({ circularValue: '[CustomCircular]' });
const circ = { id: 1 };
circ.ref = circ;
assert.strictEqual(customCircStringify(circ), '{"id":1,"ref":"[CustomCircular]"}');
}
// 3. circularValue set to TypeError throws TypeError upon encountering a circular reference
{
const throwOnCircStringify = configure({ circularValue: TypeError });
const circ = { id: 1 };
circ.ref = circ;
assert.throws(
() => throwOnCircStringify(circ),
(err) => err instanceof TypeError && /circular/i.test(err.message)
);
}
// 4. circularValue set to undefined omits circular properties from serialized object
{
const omitCircStringify = configure({ circularValue: undefined });
const circ = { id: 1 };
circ.ref = circ;
assert.strictEqual(omitCircStringify(circ), '{"id":1}');
}
// 5. deterministic: false preserves object property insertion order
{
const nonDeterministicStringify = configure({ deterministic: false });
const obj = { z: 1, a: 2, m: 3 };
assert.strictEqual(nonDeterministicStringify(obj), '{"z":1,"a":2,"m":3}');
}
// 6. bigint option: true serializes BigInt as number, false omits BigInt properties
{
const bigintTrue = configure({ bigint: true });
const bigintFalse = configure({ bigint: false });
const obj = { num: 42, big: 100n };
assert.strictEqual(bigintTrue(obj), '{"big":100,"num":42}');
assert.strictEqual(bigintFalse(obj), '{"num":42}');
}
// 7. maximumDepth limits nested serialization depth, replacing deeper objects with '[Object]' and arrays with '[Array]'
{
const depthStringify = configure({ maximumDepth: 1 });
const nested = {
level0: 'ok',
nestedObj: { level1: 'hidden' },
nestedArr: [1, 2, 3]
};
assert.strictEqual(
depthStringify(nested),
'{"level0":"ok","nestedArr":"[Array]","nestedObj":"[Object]"}'
);
}
// 8. maximumBreadth limits properties serialized per object and appends truncation indicator
{
const breadthStringify = configure({ maximumBreadth: 2 });
const wide = { a: 1, b: 2, c: 3, d: 4 };
assert.strictEqual(
breadthStringify(wide),
'{"a":1,"b":2,"...":"2 items not stringified"}'
);
}
// 9. strict: true throws Error when encountering non-JSON-serializable values
{
const strictStringify = configure({ strict: true });
assert.throws(
() => strictStringify({ fn: () => {} }),
(err) => err instanceof Error && /Object can not safely be stringified/.test(err.message)
);
assert.throws(
() => strictStringify({ value: NaN }),
(err) => err instanceof Error && /Object can not safely be stringified/.test(err.message)
);
}
console.log('Contract verification passed.');
Seeder de origen
anónimo