Ejemplo
flatted 3.4.3: fromJSON
Muestra verificada para npm flatted 3.4.3: fromJSON. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: flatted.fromJSON reconstructs…
sha256:a93897da7c15059906e30df133fe6702e81117066f850c3aafe66186c6b79f2a
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.fromJSON in pkg:npm/flatted@3.4.3
- Paquetes
- Símbolos
-
- flatted.fromJSON
- Entorno
- node 22.23.2
- Creado
- 2026-08-29T14:35:38Z
Contrato
- flatted.fromJSON reconstructs primitive values from serialized flatted structure
- flatted.fromJSON reconstructs standard objects and nested arrays without recursion
- flatted.fromJSON reconstructs self-referencing circular object references preserving object identity
- flatted.fromJSON reconstructs circular array references preserving root array identity
- flatted.fromJSON reconstructs mutually circular references between multiple distinct objects
- flatted.fromJSON preserves shared object references across distinct properties without duplication
- flatted.fromJSON reconstructs object graphs from raw JSON-parsed flatted representation
- flatted.fromJSON correctly handles empty objects and empty arrays
Archivos
- PROMPT.md
- csx.json
- index.js
- 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.fromJSON 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.fromJSON
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:f132f14b8e3b7b22aa95004adeead27f3874a09c4ebf3bc9540c90cf53246e8a","contract":["flatted.fromJSON reconstructs primitive values from serialized flatted structure","flatted.fromJSON reconstructs standard objects and nested arrays without recursion","flatted.fromJSON reconstructs self-referencing circular object references preserving object identity","flatted.fromJSON reconstructs circular array references preserving root array identity","flatted.fromJSON reconstructs mutually circular references between multiple distinct objects","flatted.fromJSON preserves shared object references across distinct properties without duplication","flatted.fromJSON reconstructs object graphs from raw JSON-parsed flatted representation","flatted.fromJSON correctly handles empty objects and empty arrays"],"goal":"verify flatted.fromJSON in pkg:npm/flatted@3.4.3","kind":"HOW","packages":["pkg:npm/flatted@3.4.3"],"schemaVersion":1,"symbols":["flatted.fromJSON"]},"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/flatted@3.4.3"],"schemaVersion":1,"subject":"pkg:npm/flatted@3.4.3","symbols":["flatted.fromJSON"],"verifierAdapter":"node-typescript@1"}
import { fromJSON, toJSON, parse, stringify } from 'flatted';
export function restoreFromJSON(value) {
return fromJSON(value);
}
export function roundtripFromJSON(value) {
return fromJSON(toJSON(value));
}
export { fromJSON, toJSON, parse, stringify };
export default fromJSON;
{
"name": "sample-flatted-fromjson",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-flatted-fromjson",
"version": "1.0.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-flatted-fromjson",
"version": "1.0.0",
"type": "module",
"private": true,
"dependencies": {
"flatted": "3.4.3"
}
}
{
"schemaVersion": 1,
"goal": "verify flatted.fromJSON in pkg:npm/flatted@3.4.3",
"kind": "HOW",
"packages": [
"pkg:npm/flatted@3.4.3"
],
"symbols": [
"flatted.fromJSON"
]
}
import assert from 'node:assert/strict';
import { toJSON, parse, stringify } from 'flatted';
import { fromJSON, restoreFromJSON, roundtripFromJSON } from '../index.js';
// 1. flatted.fromJSON reconstructs primitive values from serialized flatted structure
{
assert.strictEqual(fromJSON(toJSON(42)), 42);
assert.strictEqual(fromJSON(toJSON('hello world')), 'hello world');
assert.strictEqual(fromJSON(toJSON(true)), true);
assert.strictEqual(fromJSON(toJSON(false)), false);
assert.strictEqual(fromJSON(toJSON(null)), null);
assert.strictEqual(restoreFromJSON(toJSON(100)), 100);
}
// 2. flatted.fromJSON reconstructs standard objects and nested arrays without recursion
{
const original = {
title: 'CodeSampleX',
count: 10,
tags: ['testing', 'samples', 'npm'],
nested: { active: true, score: 99.5 }
};
const restored = fromJSON(toJSON(original));
assert.deepStrictEqual(restored, original);
assert.notStrictEqual(restored, original, 'restored object should be a new instance');
assert.notStrictEqual(restored.nested, original.nested);
assert.notStrictEqual(restored.tags, original.tags);
}
// 3. flatted.fromJSON reconstructs self-referencing circular object references preserving object identity
{
const circular = { name: 'self-node', value: 1 };
circular.self = circular;
circular.nested = { parent: circular };
const restored = roundtripFromJSON(circular);
assert.strictEqual(restored.name, 'self-node');
assert.strictEqual(restored.value, 1);
assert.strictEqual(restored.self, restored, 'self reference must point back to restored root object');
assert.strictEqual(restored.nested.parent, restored, 'nested parent reference must point back to restored root');
}
// 4. flatted.fromJSON reconstructs circular array references preserving root array identity
{
const circularArr = ['root', 42];
circularArr.push(circularArr);
const restored = fromJSON(toJSON(circularArr));
assert.strictEqual(Array.isArray(restored), true);
assert.strictEqual(restored[0], 'root');
assert.strictEqual(restored[1], 42);
assert.strictEqual(restored[2], restored, 'array element must point back to restored array itself');
}
// 5. flatted.fromJSON reconstructs mutually circular references between multiple distinct objects
{
const first = { label: 'first' };
const second = { label: 'second' };
first.partner = second;
second.partner = first;
const restored = fromJSON(toJSON(first));
assert.strictEqual(restored.label, 'first');
assert.strictEqual(restored.partner.label, 'second');
assert.strictEqual(restored.partner.partner, restored, 'mutual circular link must be preserved');
}
// 6. flatted.fromJSON preserves shared object references across distinct properties without duplication
{
const sharedLeaf = { leafId: 'leaf-101', timestamp: 123456 };
const tree = {
branchA: { item: sharedLeaf },
branchB: { item: sharedLeaf },
list: [sharedLeaf]
};
const restored = fromJSON(toJSON(tree));
assert.strictEqual(restored.branchA.item, restored.branchB.item, 'shared reference must remain strictly identical');
assert.strictEqual(restored.list[0], restored.branchA.item, 'list element reference must match branch item');
// Mutating one reference should reflect on all shared points
restored.branchA.item.leafId = 'leaf-updated';
assert.strictEqual(restored.branchB.item.leafId, 'leaf-updated');
assert.strictEqual(restored.list[0].leafId, 'leaf-updated');
}
// 7. flatted.fromJSON reconstructs object graphs from raw JSON-parsed flatted representation
{
const source = { greeting: 'hello', numbers: [1, 2, 3] };
const flattedString = stringify(source);
const rawArray = JSON.parse(flattedString);
assert.strictEqual(Array.isArray(rawArray), true);
const restored = restoreFromJSON(rawArray);
assert.deepStrictEqual(restored, source);
}
// 8. flatted.fromJSON correctly handles empty objects and empty arrays
{
assert.deepStrictEqual(fromJSON(toJSON({})), {});
assert.deepStrictEqual(fromJSON(toJSON([])), []);
}
console.log('Contract verification finished successfully.');
Seeder de origen
anónimo