Beispiel
flatted 3.4.3: parse
Verifiziertes Beispiel für npm flatted 3.4.3: parse. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: parse restores primitive values…
sha256:2510f10e8a238e184972655cc9998e2c976ad77511638bff0b42784146b1c8d4
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.parse in pkg:npm/flatted@3.4.3
- Pakete
- Symbole
-
- flatted.parse
- Umgebung
- node 22.23.2
- Erstellt
- 2026-08-29T14:39:38Z
Contract
- parse restores primitive values from a flatted JSON string
- parse reconstructs plain nested objects and arrays without circular references
- parse reconstructs self-referencing circular objects and arrays
- parse reconstructs mutually recursive cyclic object graphs
- parse preserves reference identity across multiple occurrences of shared objects
- parse transforms values using a custom reviver function
- parse throws SyntaxError when input is malformed or invalid JSON
- flatted namespace parse and named parse export provide identical functionality
Dateien
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- 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.parse 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.parse
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:3ec069fb92b1f3bace6eef3b0a393c174204f9d342ce6da63d172d696d6f43de","contract":["parse restores primitive values from a flatted JSON string","parse reconstructs plain nested objects and arrays without circular references","parse reconstructs self-referencing circular objects and arrays","parse reconstructs mutually recursive cyclic object graphs","parse preserves reference identity across multiple occurrences of shared objects","parse transforms values using a custom reviver function","parse throws SyntaxError when input is malformed or invalid JSON","flatted namespace parse and named parse export provide identical functionality"],"goal":"verify flatted.parse in pkg:npm/flatted@3.4.3","kind":"HOW","packages":["pkg:npm/flatted@3.4.3"],"schemaVersion":1,"symbols":["flatted.parse"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","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.parse"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-flatted-parse",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-flatted-parse",
"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-flatted-parse",
"version": "1.0.0",
"type": "module",
"private": true,
"license": "MIT-0",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"flatted": "3.4.3"
}
}
{
"schemaVersion": 1,
"goal": "verify flatted.parse in pkg:npm/flatted@3.4.3",
"kind": "HOW",
"packages": [
"pkg:npm/flatted@3.4.3"
],
"symbols": [
"flatted.parse"
]
}
import * as flatted from 'flatted';
const { parse, stringify, fromJSON, toJSON } = flatted;
/**
* Parses a flatted JSON string, resolving circular and recursive references.
*
* @param {string} text - The flatted JSON string to parse.
* @param {Function} [reviver] - Optional reviver function to transform parsed values.
* @returns {*} The parsed value or reconstituted object hierarchy.
*/
export function parseFlatted(text, reviver) {
return parse(text, reviver);
}
/**
* Serializes a value to a flatted JSON string capable of preserving circular references.
*
* @param {*} value - The value to serialize.
* @param {Function|Array} [replacer] - Optional replacer function or property whitelist.
* @param {string|number} [space] - Formatting whitespace.
* @returns {string} The serialized flatted JSON string.
*/
export function stringifyFlatted(value, replacer, space) {
return stringify(value, replacer, space);
}
export { parse, stringify, fromJSON, toJSON, flatted };
export default { parse, stringify, fromJSON, toJSON };
import assert from 'node:assert/strict';
import * as flatted from 'flatted';
import { parse, stringify } from 'flatted';
import { parseFlatted, stringifyFlatted } from '../src/index.mjs';
// 1. parse restores primitive values from a flatted JSON string
{
assert.equal(parse(stringify('hello')), 'hello');
assert.equal(parse(stringify(42)), 42);
assert.equal(parse(stringify(true)), true);
assert.equal(parse(stringify(false)), false);
assert.equal(parse(stringify(null)), null);
assert.equal(parseFlatted(stringifyFlatted('world')), 'world');
}
// 2. parse reconstructs plain nested objects and arrays without circular references
{
const obj = { name: 'Alice', age: 30, items: [1, 2, 3], nested: { valid: true } };
const parsed = parse(stringify(obj));
assert.deepEqual(parsed, obj);
assert.deepEqual(parseFlatted(stringifyFlatted(obj)), obj);
}
// 3. parse reconstructs self-referencing circular objects and arrays
{
const circularObj = { name: 'node' };
circularObj.self = circularObj;
const parsedObj = parse(stringify(circularObj));
assert.equal(parsedObj.name, 'node');
assert.equal(parsedObj.self, parsedObj);
assert.equal(parsedObj.self.self, parsedObj);
const circularArr = ['first'];
circularArr.push(circularArr);
const parsedArr = parse(stringify(circularArr));
assert.equal(parsedArr[0], 'first');
assert.equal(parsedArr[1], parsedArr);
assert.equal(parsedArr[1][1], parsedArr);
}
// 4. parse reconstructs mutually recursive cyclic object graphs
{
const parent = { name: 'parent' };
const child = { name: 'child', parent };
parent.child = child;
const parsed = parse(stringify(parent));
assert.equal(parsed.name, 'parent');
assert.equal(parsed.child.name, 'child');
assert.equal(parsed.child.parent, parsed);
assert.equal(parsed.child.parent.child, parsed.child);
}
// 5. parse preserves reference identity across multiple occurrences of shared objects
{
const shared = { id: 100, label: 'shared-data' };
const container = { a: shared, b: shared, list: [shared] };
const parsed = parse(stringify(container));
assert.equal(parsed.a, parsed.b);
assert.equal(parsed.a, parsed.list[0]);
parsed.a.label = 'modified';
assert.equal(parsed.b.label, 'modified');
assert.equal(parsed.list[0].label, 'modified');
}
// 6. parse transforms values using a custom reviver function
{
const data = { timestamp: '2026-01-01T00:00:00.000Z', count: '10' };
const serialized = stringify(data);
const parsed = parse(serialized, (key, value) => {
if (key === 'timestamp') return new Date(value);
if (key === 'count') return Number(value);
return value;
});
assert.ok(parsed.timestamp instanceof Date);
assert.equal(parsed.timestamp.toISOString(), '2026-01-01T00:00:00.000Z');
assert.equal(parsed.count, 10);
}
// 7. parse throws SyntaxError when input is malformed or invalid JSON
{
assert.throws(() => parse('invalid json'), SyntaxError);
assert.throws(() => parse('{unquoted: 123}'), SyntaxError);
}
// 8. flatted namespace parse and named parse export provide identical functionality
{
assert.equal(flatted.parse, parse);
const data = { x: 1 };
data.loop = data;
const result1 = flatted.parse(flatted.stringify(data));
const result2 = parse(stringify(data));
assert.deepEqual(result1.x, result2.x);
assert.equal(result1.loop, result1);
assert.equal(result2.loop, result2);
}
console.log('Contract tests passed successfully.');
Ursprungs-Seeder
anonym