Exemplo
json-stable-stringify-without-jsonify 1.0.1: stringify
Amostra verificada para npm json-stable-stringify-without-jsonify 1.0.1: stringify. O contrato rodou em node 22 · linux debian/x64 · docker e passou.
sha256:69ffc299da3e9cb29a64c81af3890ac1dfe903b825797277e5d81e97363e2a8b
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux 24 · ubuntu · glibc 2.39 x64 npm
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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-01 |
Caso
HOW- Objetivo
- verify stringify in pkg:npm/json-stable-stringify-without-jsonify@1.0.1
- Símbolos
-
- stringify
- Criado
- 2026-09-01T19:51:48Z
Contrato
- stringify deterministically sorts object keys in alphabetical order regardless of insertion order
- stringify supports custom indentation formatting using numeric and string space options
- stringify supports custom key comparator functions to define explicit sorting order
- stringify supports custom replacer functions to transform or filter object properties
- stringify safely handles circular references by returning a placeholder when cycles option is enabled
- stringify throws a TypeError on circular references when cycles option is disabled
- stringify respects custom toJSON serialization methods on objects
- stringify handles nested structures containing arrays, objects, and primitive values
Arquivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
Código-fonte
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 stringify in pkg:npm/json-stable-stringify-without-jsonify@1.0.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/json-stable-stringify-without-jsonify@1.0.1
Demonstrate these symbols/APIs:
- stringify
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:a508428e5d204c21b9f1bb6bdbe463c8239eb056a6746c5434b02f4689d8fd9c","contract":["stringify deterministically sorts object keys in alphabetical order regardless of insertion order","stringify supports custom indentation formatting using numeric and string space options","stringify supports custom key comparator functions to define explicit sorting order","stringify supports custom replacer functions to transform or filter object properties","stringify safely handles circular references by returning a placeholder when cycles option is enabled","stringify throws a TypeError on circular references when cycles option is disabled","stringify respects custom toJSON serialization methods on objects","stringify handles nested structures containing arrays, objects, and primitive values"],"goal":"verify stringify in pkg:npm/json-stable-stringify-without-jsonify@1.0.1","kind":"HOW","packages":["pkg:npm/json-stable-stringify-without-jsonify@1.0.1"],"schemaVersion":1,"symbols":["stringify"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/json-stable-stringify-without-jsonify@1.0.1"],"schemaVersion":1,"subject":"pkg:npm/json-stable-stringify-without-jsonify@1.0.1","symbols":["stringify"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-json-stable-stringify-without-jsonify",
"version": "1.0.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-json-stable-stringify-without-jsonify",
"version": "1.0.1",
"license": "MIT-0",
"dependencies": {
"json-stable-stringify-without-jsonify": "1.0.1"
}
},
"node_modules/json-stable-stringify-without-jsonify": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz",
"integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==",
"license": "MIT"
}
}
}
{
"name": "sample-json-stable-stringify-without-jsonify",
"version": "1.0.1",
"type": "module",
"private": true,
"license": "MIT-0",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"json-stable-stringify-without-jsonify": "1.0.1"
}
}
{
"schemaVersion": 1,
"goal": "verify stringify in pkg:npm/json-stable-stringify-without-jsonify@1.0.1",
"kind": "HOW",
"packages": [
"pkg:npm/json-stable-stringify-without-jsonify@1.0.1"
],
"symbols": [
"stringify"
]
}
import stringify from 'json-stable-stringify-without-jsonify';
/**
* Deterministically stringifies a JavaScript value into a stable JSON string.
* @param {any} obj The value to serialize
* @param {object|Function} [opts] Options object or comparison function
* @returns {string|undefined} The serialized JSON string
*/
export function stableStringify(obj, opts) {
return stringify(obj, opts);
}
export { stringify };
export default stringify;
import assert from 'node:assert/strict';
import { stringify, stableStringify } from '../src/index.mjs';
// 1. stringify deterministically sorts object keys in alphabetical order regardless of insertion order
{
const obj1 = { c: 3, a: 1, b: 2 };
const obj2 = { b: 2, c: 3, a: 1 };
const result1 = stringify(obj1);
const result2 = stableStringify(obj2);
assert.equal(result1, '{"a":1,"b":2,"c":3}');
assert.equal(result2, '{"a":1,"b":2,"c":3}');
assert.equal(result1, result2);
}
// 2. stringify supports custom indentation formatting using numeric and string space options
{
const obj = { b: 2, a: 1 };
const formattedWithNumber = stringify(obj, { space: 2 });
assert.equal(formattedWithNumber, '{\n "a": 1,\n "b": 2\n}');
const formattedWithString = stringify(obj, { space: '\t' });
assert.equal(formattedWithString, '{\n\t"a": 1,\n\t"b": 2\n}');
}
// 3. stringify supports custom key comparator functions to define explicit sorting order
{
const obj = { apple: 10, zebra: 20, banana: 30 };
const customSorted = stringify(obj, {
cmp: (a, b) => b.key.localeCompare(a.key)
});
assert.equal(customSorted, '{"zebra":20,"banana":30,"apple":10}');
const cmpShorthand = stringify(obj, (a, b) => b.key.localeCompare(a.key));
assert.equal(cmpShorthand, '{"zebra":20,"banana":30,"apple":10}');
}
// 4. stringify supports custom replacer functions to transform or filter object properties
{
const obj = { id: 1, secret: 'password123', visible: true };
const filtered = stringify(obj, {
replacer: (key, value) => {
if (key === 'secret') return undefined;
if (typeof value === 'number') return value * 10;
return value;
}
});
assert.equal(filtered, '{"id":10,"visible":true}');
}
// 5. stringify safely handles circular references by returning a placeholder when cycles option is enabled
{
const circularObj = { name: 'cycle-test' };
circularObj.self = circularObj;
const result = stringify(circularObj, { cycles: true });
assert.equal(result, '{"name":"cycle-test","self":"__cycle__"}');
}
// 6. stringify throws a TypeError on circular references when cycles option is disabled
{
const circularObj = { name: 'cycle-error' };
circularObj.self = circularObj;
assert.throws(
() => stringify(circularObj),
(err) => err instanceof TypeError && /Converting circular structure to JSON/.test(err.message)
);
}
// 7. stringify respects custom toJSON serialization methods on objects
{
const customObj = {
x: 10,
toJSON() {
return { normalized: this.x * 2 };
}
};
const result = stringify({ item: customObj });
assert.equal(result, '{"item":{"normalized":20}}');
}
// 8. stringify handles nested structures containing arrays, objects, and primitive values
{
const nested = {
users: [
{ z: 'last', a: 'first' },
{ y: 2, b: 1 }
],
count: 2,
active: true,
empty: null
};
const result = stringify(nested);
assert.equal(
result,
'{"active":true,"count":2,"empty":null,"users":[{"a":"first","z":"last"},{"b":1,"y":2}]}'
);
}
console.log('Contract assertions passed.');
Seeder de origem
anônimo