サンプル
flatted 3.4.3: toJSON
検証済みサンプル — npm flatted 3.4.3: toJSON. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: flatted.toJSON converts primitive values into array…
sha256:409ab647c91f63e66d95a274377f536727b484865a868ae4e3c40bea0b0a202c
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
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.toJSON in pkg:npm/flatted@3.4.3
- パッケージ
- シンボル
-
- flatted.toJSON
- 環境
- node 22.23.2
- 作成日
- 2026-08-29T14:42:13Z
コントラクト
- 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
ファイル
- PROMPT.md
- csx.json
- 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.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');
オリジンシーダー
匿名