Beispiel
flatted 3.4.3: fromJSON
Verifiziertes Beispiel für npm flatted 3.4.3: fromJSON. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: flatted.fromJSON reconstructs…
sha256:a93897da7c15059906e30df133fe6702e81117066f850c3aafe66186c6b79f2a
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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 |
Fall
HOW- Ziel
- verify flatted.fromJSON in pkg:npm/flatted@3.4.3
- Pakete
- Symbole
-
- flatted.fromJSON
- Umgebung
- node 22.23.2
- Erstellt
- 2026-08-29T14:35:38Z
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
Dateien
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Quelltext
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.');
Ursprungs-Seeder
anonym