Exemple
pretty-format 27.5.1: format
Échantillon vérifié pour npm pretty-format 27.5.1: format. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a réussi.
sha256:75915dd9e63ee3984613374bdd7fe31f1687941b94569c016ed07be3a7991b44
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-04 |
Cas
HOW- Objectif
- verify pretty-format.format in pkg:npm/pretty-format@27.5.1
- Paquets
- Symboles
-
- pretty-format.format
- Créé
- 2026-09-04T09:21:37Z
Contrat
- format formats primitives and nested objects into readable strings
- format supports custom indentation width via indent option
- format detects and handles circular references with [Circular]
- format truncates nested structure traversal with maxDepth option
- format formats compactly without newlines when min option is true
- format supports custom serialization via plugins option
Fichiers
- .npmrc
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
Code source
audit=false
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 pretty-format.format in pkg:npm/pretty-format@27.5.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/pretty-format@27.5.1
Demonstrate these symbols/APIs:
- pretty-format.format
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:8f60413dceaa59e3075e27c6bd22f18c7c81fc8ba0acd2589905f3c3dfb64180","contract":["format formats primitives and nested objects into readable strings","format supports custom indentation width via indent option","format detects and handles circular references with [Circular]","format truncates nested structure traversal with maxDepth option","format formats compactly without newlines when min option is true","format supports custom serialization via plugins option"],"goal":"verify pretty-format.format in pkg:npm/pretty-format@27.5.1","kind":"HOW","packages":["pkg:npm/pretty-format@27.5.1"],"schemaVersion":1,"symbols":["pretty-format.format"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/pretty-format@27.5.1"],"schemaVersion":1,"subject":"pkg:npm/pretty-format@27.5.1","symbols":["pretty-format.format"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-pretty-format",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-pretty-format",
"version": "1.0.0",
"dependencies": {
"pretty-format": "27.5.1"
}
},
"node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/ansi-styles": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz",
"integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==",
"license": "MIT",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/pretty-format": {
"version": "27.5.1",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz",
"integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==",
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1",
"ansi-styles": "^5.0.0",
"react-is": "^17.0.1"
},
"engines": {
"node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
}
},
"node_modules/react-is": {
"version": "17.0.2",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==",
"license": "MIT"
}
}
}
{
"name": "sample-pretty-format",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of pretty-format.format",
"main": "src/index.js",
"dependencies": {
"pretty-format": "27.5.1"
}
}
{
"schemaVersion": 1,
"goal": "verify pretty-format.format in pkg:npm/pretty-format@27.5.1",
"kind": "HOW",
"packages": [
"pkg:npm/pretty-format@27.5.1"
],
"symbols": [
"pretty-format.format"
]
}
const { format } = require('pretty-format');
function formatData(value, options = {}) {
return format(value, options);
}
function formatCompact(value) {
return format(value, { min: true });
}
function formatWithMaxDepth(value, maxDepth = 2) {
return format(value, { maxDepth });
}
module.exports = {
format,
formatData,
formatCompact,
formatWithMaxDepth
};
import assert from 'node:assert';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { format, formatData, formatCompact, formatWithMaxDepth } = require('../src/index.js');
// 1. Basic formatting for primitives and nested objects
const basicObj = { name: 'sample', count: 42, active: true, list: [1, 2] };
const basicFormatted = format(basicObj);
assert.strictEqual(typeof basicFormatted, 'string', 'format should return a string');
assert.match(basicFormatted, /"name": "sample"/, 'format should include key-value pairs');
assert.match(basicFormatted, /"count": 42/, 'format should format numbers');
assert.match(basicFormatted, /Array \[/, 'format should format arrays');
// 2. Custom indentation
const customIndentFormatted = format({ key: 'val' }, { indent: 4 });
assert.match(customIndentFormatted, /^ {4}"key": "val"/m, 'format should respect 4-space indentation');
// 3. Circular reference handling
const circularObj = { title: 'node' };
circularObj.self = circularObj;
const circularFormatted = format(circularObj);
assert.match(circularFormatted, /\[Circular\]/, 'format should handle circular references');
// 4. maxDepth option
const deeplyNested = { a: { b: { c: { d: 'deep' } } } };
const depthFormatted = formatWithMaxDepth(deeplyNested, 2);
assert.match(depthFormatted, /"b": \[Object\]/, 'format should truncate beyond maxDepth');
// 5. Min option (compact)
const compactFormatted = formatCompact({ a: 1, b: 2 });
assert.strictEqual(compactFormatted, '{"a": 1, "b": 2}', 'format should format compactly on single line');
// 6. Custom plugin
const customPlugin = {
test: (val) => val && val.__customType === 'UserToken',
serialize: (val) => `Token(${val.id})`
};
const pluginFormatted = format({ user: { __customType: 'UserToken', id: '12345' } }, { plugins: [customPlugin] });
assert.match(pluginFormatted, /Token\(12345\)/, 'format should apply custom plugins');
console.log('Contract tests passed successfully.');
Seeder d'origine
anonyme