샘플
flatted 3.4.3: fromJSON
검증된 샘플 — npm flatted 3.4.3: fromJSON. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: flatted.fromJSON reconstructs primitive values from…
sha256:a93897da7c15059906e30df133fe6702e81117066f850c3aafe66186c6b79f2a
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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 |
케이스
HOW- 목표
- verify flatted.fromJSON in pkg:npm/flatted@3.4.3
- 패키지
- 심벌
-
- flatted.fromJSON
- 환경
- node 22.23.2
- 생성일
- 2026-08-29T14:35:38Z
컨트랙트
- 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
파일
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
소스
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.');
오리진 시더
익명