Ejemplo
flatted 3.4.3: toJSON
Muestra verificada para npm flatted 3.4.3: toJSON. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: flatted.toJSON converts primitive…
sha256:409ab647c91f63e66d95a274377f536727b484865a868ae4e3c40bea0b0a202c
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@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-29 |
Caso
HOW- Objetivo
- verify flatted.toJSON in pkg:npm/flatted@3.4.3
- Paquetes
- Símbolos
-
- flatted.toJSON
- Entorno
- node 22.23.2
- Creado
- 2026-08-29T14:42:13Z
Contrato
- flatted.toJSON converts primitive values into array representation
- flatted.toJSON converts objects and arrays into indexed flat array representation
- flatted.toJSON converts self-referencing circular objects into flat array representation without recursion errors
- flatted.toJSON converts mutually circular objects into flat array representation
- flatted.toJSON preserves shared object references across multiple properties with single indexed instance
- flatted.toJSON output serialized with JSON.stringify matches flatted.stringify output
- flatted.fromJSON reconstructs original circular object graph from flatted.toJSON output
- flatted.toJSON handles nested arrays containing objects and circular references
Archivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
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 flatted.toJSON in pkg:npm/flatted@3.4.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/flatted@3.4.3
Demonstrate these symbols/APIs:
- flatted.toJSON
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:2a7ddb42c0228965c30b740dd47f567e7714306d51c6df4a7ec6296261b41f91","contract":["flatted.toJSON converts primitive values into array representation","flatted.toJSON converts objects and arrays into indexed flat array representation","flatted.toJSON converts self-referencing circular objects into flat array representation without recursion errors","flatted.toJSON converts mutually circular objects into flat array representation","flatted.toJSON preserves shared object references across multiple properties with single indexed instance","flatted.toJSON output serialized with JSON.stringify matches flatted.stringify output","flatted.fromJSON reconstructs original circular object graph from flatted.toJSON output","flatted.toJSON handles nested arrays containing objects and circular references"],"goal":"verify flatted.toJSON in pkg:npm/flatted@3.4.3","kind":"HOW","packages":["pkg:npm/flatted@3.4.3"],"schemaVersion":1,"symbols":["flatted.toJSON"]},"contractCommand":["node","test/contract.mjs"],"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/flatted@3.4.3"],"schemaVersion":1,"subject":"pkg:npm/flatted@3.4.3","symbols":["flatted.toJSON"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-3979932717",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-3979932717",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"flatted": "3.4.3"
}
},
"node_modules/flatted": {
"version": "3.4.3",
"resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.3.tgz",
"integrity": "sha512-/zipXxyO6rGvuNGDiULY9MvEGSkb2gaG4GGH4ygMi0ZZzyMHdUZBmntJmx5x1G2VuPytCwGN4xsJP6cw+sK+vQ==",
"license": "ISC"
}
}
}
{
"name": "sample-3979932717",
"version": "1.0.0",
"description": "verify flatted.toJSON in pkg:npm/flatted@3.4.3",
"main": "index.js",
"scripts": {
"test": "node test/contract.mjs"
},
"license": "MIT-0",
"dependencies": {
"flatted": "3.4.3"
}
}
{
"schemaVersion": 1,
"goal": "verify flatted.toJSON in pkg:npm/flatted@3.4.3",
"kind": "HOW",
"packages": [
"pkg:npm/flatted@3.4.3"
],
"symbols": [
"flatted.toJSON"
]
}
import assert from 'node:assert/strict';
import { toJSON, fromJSON, stringify } from 'flatted';
// 1. flatted.toJSON converts primitive values into array representation
{
assert.deepEqual(toJSON(42), [42]);
assert.deepEqual(toJSON('hello'), ['hello']);
assert.deepEqual(toJSON(true), [true]);
assert.deepEqual(toJSON(null), [null]);
}
// 2. flatted.toJSON converts objects and arrays into indexed flat array representation
{
const obj = { a: 1, b: 'two' };
const arr = toJSON(obj);
assert.ok(Array.isArray(arr));
assert.equal(arr[0].a, 1);
assert.equal(arr[0].b, '1');
assert.equal(arr[1], 'two');
const list = [10, 20, 30];
const listArr = toJSON(list);
assert.ok(Array.isArray(listArr));
assert.deepEqual(listArr[0], [10, 20, 30]);
}
// 3. flatted.toJSON converts self-referencing circular objects into flat array representation without recursion errors
{
const circular = { id: 1 };
circular.self = circular;
const jsonArr = toJSON(circular);
assert.ok(Array.isArray(jsonArr));
assert.equal(jsonArr[0].id, 1);
assert.equal(jsonArr[0].self, '0');
}
// 4. flatted.toJSON converts mutually circular objects into flat array representation
{
const a = { id: 1 };
const b = { id: 2 };
a.peer = b;
b.peer = a;
const jsonArr = toJSON(a);
assert.ok(Array.isArray(jsonArr));
assert.equal(jsonArr.length, 2);
assert.equal(jsonArr[0].id, 1);
assert.equal(jsonArr[0].peer, '1');
assert.equal(jsonArr[1].id, 2);
assert.equal(jsonArr[1].peer, '0');
}
// 5. flatted.toJSON preserves shared object references across multiple properties with single indexed instance
{
const shared = { value: 100 };
const container = { first: shared, second: shared };
const jsonArr = toJSON(container);
assert.ok(Array.isArray(jsonArr));
assert.equal(jsonArr[0].first, '1');
assert.equal(jsonArr[0].second, '1');
assert.equal(jsonArr[1].value, 100);
}
// 6. flatted.toJSON output serialized with JSON.stringify matches flatted.stringify output
{
const complex = { num: 1, str: 'test', list: [1, 2] };
complex.self = complex;
const viaToJSON = JSON.stringify(toJSON(complex));
const viaStringify = stringify(complex);
assert.equal(viaToJSON, viaStringify);
}
// 7. flatted.fromJSON reconstructs original circular object graph from flatted.toJSON output
{
const original = { id: 42, meta: 'data' };
original.cycle = original;
const jsonArr = toJSON(original);
const reconstructed = fromJSON(jsonArr);
assert.equal(reconstructed.id, 42);
assert.equal(reconstructed.meta, 'data');
assert.equal(reconstructed.cycle, reconstructed);
}
// 8. flatted.toJSON handles nested arrays containing objects and circular references
{
const item = { val: 1 };
const arr = [item, [item]];
item.parent = arr;
const jsonArr = toJSON(arr);
assert.ok(Array.isArray(jsonArr));
const restored = fromJSON(jsonArr);
assert.equal(restored[0].val, 1);
assert.equal(restored[1][0], restored[0]);
assert.equal(restored[0].parent, restored);
}
console.log('Contract passed');
Seeder de origen
anónimo