示例
safe-stable-stringify 2.5.0: configure
已验证示例 — npm safe-stable-stringify 2.5.0: configure. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: Calling safe-stable-stringify.configure returns a…
sha256:747bf30351d648b805b3ddb3271daa17be275b7679d792fc61deebad576368fc
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 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@1 |
2026-08-21 |
案例
HOW- 目标
- verify safe-stable-stringify.configure in pkg:npm/safe-stable-stringify@2.5.0
- 符号
-
- safe-stable-stringify.configure
- 环境
- node 22.23.2
- 创建时间
- 2026-08-21T04:31:12Z
契约
- 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.
文件
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- 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 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.');
原始种子者
匿名