CodeSampleX

Beispiel

safe-stable-stringify 2.5.0: configure

Verifiziertes Beispiel für npm safe-stable-stringify 2.5.0: configure. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand.

sha256:747bf30351d648b805b3ddb3271daa17be275b7679d792fc61deebad576368fc

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@1
2026-08-21

Fall

HOW
Ziel
verify safe-stable-stringify.configure in pkg:npm/safe-stable-stringify@2.5.0
Pakete
Symbole
  • safe-stable-stringify.configure
Umgebung
node 22.23.2
Erstellt
2026-08-21T04:31:12Z

Contract

  1. Calling safe-stable-stringify.configure returns a custom stringify function tailored with the specified options.
  2. Setting circularValue to a custom string replaces circular references with that string during serialization.
  3. Setting circularValue to TypeError causes serialization to throw a TypeError when a circular reference is encountered.
  4. Setting circularValue to undefined omits circular properties from the serialized JSON output.
  5. Setting deterministic to false preserves object property insertion order instead of sorting keys alphabetically.
  6. Setting bigint to true serializes BigInt values as numbers, while bigint: false omits BigInt properties.
  7. Setting maximumDepth limits nested serialization depth, replacing deeper objects with '[Object]' and arrays with '[Array]'.
  8. Setting maximumBreadth limits the number of serialized properties per object and appends a truncation summary.
  9. Setting strict to true throws an Error when encountering non-JSON-serializable values such as functions or NaN.

Dateien

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.js

Quellartefakt herunterladen (tar.gz)

Quelltext

PROMPT.md
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 safe-stable-stringify.configure in pkg:npm/safe-stable-stringify@2.5.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/safe-stable-stringify@2.5.0
Demonstrate these symbols/APIs:
  - safe-stable-stringify.configure
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

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.
csx.json
{"case":{"caseId":"case:sha256:df2874c6b142aabc6fa60aa909f07fcaf20de1e87de85cfbd26ee4bf2fecaec4","constraints":{"executionContext":"node"},"contract":["Calling safe-stable-stringify.configure returns a custom stringify function tailored with the specified options.","Setting circularValue to a custom string replaces circular references with that string during serialization.","Setting circularValue to TypeError causes serialization to throw a TypeError when a circular reference is encountered.","Setting circularValue to undefined omits circular properties from the serialized JSON output.","Setting deterministic to false preserves object property insertion order instead of sorting keys alphabetically.","Setting bigint to true serializes BigInt values as numbers, while bigint: false omits BigInt properties.","Setting maximumDepth limits nested serialization depth, replacing deeper objects with '[Object]' and arrays with '[Array]'.","Setting maximumBreadth limits the number of serialized properties per object and appends a truncation summary.","Setting strict to true throws an Error when encountering non-JSON-serializable values such as functions or NaN."],"goal":"verify safe-stable-stringify.configure in pkg:npm/safe-stable-stringify@2.5.0","kind":"HOW","packages":["pkg:npm/safe-stable-stringify@2.5.0"],"schemaVersion":1,"symbols":["safe-stable-stringify.configure"]},"contractCommand":["node","test/contract.js"],"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/safe-stable-stringify@2.5.0"],"schemaVersion":1,"subject":"pkg:npm/safe-stable-stringify@2.5.0","symbols":["safe-stable-stringify.configure"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-safe-stable-stringify",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-safe-stable-stringify",
      "version": "1.0.0",
      "dependencies": {
        "safe-stable-stringify": "2.5.0"
      }
    },
    "node_modules/safe-stable-stringify": {
      "version": "2.5.0",
      "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz",
      "integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==",
      "license": "MIT",
      "engines": {
        "node": ">=10"
      }
    }
  }
}
package.json
{
  "name": "sample-safe-stable-stringify",
  "version": "1.0.0",
  "private": true,
  "description": "verify safe-stable-stringify.configure in pkg:npm/safe-stable-stringify@2.5.0",
  "dependencies": {
    "safe-stable-stringify": "2.5.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify safe-stable-stringify.configure in pkg:npm/safe-stable-stringify@2.5.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/safe-stable-stringify@2.5.0"
  ],
  "symbols": [
    "safe-stable-stringify.configure"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.js
const assert = require('node:assert');
const { configure, stringify: defaultStringify } = require('safe-stable-stringify');

// 1. Default stringify behavior (deterministic key sorting and default circular marker)
{
  const obj = { z: 1, a: 2, m: 3 };
  assert.strictEqual(defaultStringify(obj), '{"a":2,"m":3,"z":1}');

  const circ = { name: 'root' };
  circ.self = circ;
  assert.strictEqual(defaultStringify(circ), '{"name":"root","self":"[Circular]"}');
}

// 2. Custom circularValue string replaces circular references with that string
{
  const customCircStringify = configure({ circularValue: '[CustomCircular]' });
  const circ = { id: 1 };
  circ.ref = circ;
  assert.strictEqual(customCircStringify(circ), '{"id":1,"ref":"[CustomCircular]"}');
}

// 3. circularValue set to TypeError throws TypeError upon encountering a circular reference
{
  const throwOnCircStringify = configure({ circularValue: TypeError });
  const circ = { id: 1 };
  circ.ref = circ;
  assert.throws(
    () => throwOnCircStringify(circ),
    (err) => err instanceof TypeError && /circular/i.test(err.message)
  );
}

// 4. circularValue set to undefined omits circular properties from serialized object
{
  const omitCircStringify = configure({ circularValue: undefined });
  const circ = { id: 1 };
  circ.ref = circ;
  assert.strictEqual(omitCircStringify(circ), '{"id":1}');
}

// 5. deterministic: false preserves object property insertion order
{
  const nonDeterministicStringify = configure({ deterministic: false });
  const obj = { z: 1, a: 2, m: 3 };
  assert.strictEqual(nonDeterministicStringify(obj), '{"z":1,"a":2,"m":3}');
}

// 6. bigint option: true serializes BigInt as number, false omits BigInt properties
{
  const bigintTrue = configure({ bigint: true });
  const bigintFalse = configure({ bigint: false });
  const obj = { num: 42, big: 100n };

  assert.strictEqual(bigintTrue(obj), '{"big":100,"num":42}');
  assert.strictEqual(bigintFalse(obj), '{"num":42}');
}

// 7. maximumDepth limits nested serialization depth, replacing deeper objects with '[Object]' and arrays with '[Array]'
{
  const depthStringify = configure({ maximumDepth: 1 });
  const nested = {
    level0: 'ok',
    nestedObj: { level1: 'hidden' },
    nestedArr: [1, 2, 3]
  };
  assert.strictEqual(
    depthStringify(nested),
    '{"level0":"ok","nestedArr":"[Array]","nestedObj":"[Object]"}'
  );
}

// 8. maximumBreadth limits properties serialized per object and appends truncation indicator
{
  const breadthStringify = configure({ maximumBreadth: 2 });
  const wide = { a: 1, b: 2, c: 3, d: 4 };
  assert.strictEqual(
    breadthStringify(wide),
    '{"a":1,"b":2,"...":"2 items not stringified"}'
  );
}

// 9. strict: true throws Error when encountering non-JSON-serializable values
{
  const strictStringify = configure({ strict: true });
  assert.throws(
    () => strictStringify({ fn: () => {} }),
    (err) => err instanceof Error && /Object can not safely be stringified/.test(err.message)
  );
  assert.throws(
    () => strictStringify({ value: NaN }),
    (err) => err instanceof Error && /Object can not safely be stringified/.test(err.message)
  );
}

console.log('Contract verification passed.');

Ursprungs-Seeder

anonym