CodeSampleX

Exemplo

object-inspect 1.13.4

Amostra verificada para npm object-inspect 1.13.4. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: formatValue returns formatted string…

sha256:d288f274c1109d7a141e8179af8ee2b0d3fc78029569b6bca6562801bf918fb8

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
2
Chaves de assinatura que o compilaram
1
Ambiente declarado node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-20
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-07

Caso

HOW
Objetivo
verify pkg:npm/object-inspect@1.13.4
Pacotes
Ambiente
node 22.23.2
Criado
2026-08-20T13:26:05Z

Contrato

  1. formatValue returns formatted string representations for objects and primitives
  2. formatObject safely inspects circular data structures without throwing
  3. supports depth option to limit inspection depth of nested structures
  4. supports quoteStyle option for choosing single or double string quotes
  5. supports maxStringLength option to truncate strings exceeding maximum length

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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 pkg:npm/object-inspect@1.13.4
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/object-inspect@1.13.4
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:ca4ad612bbf6d228537016f382bdc9b7c71bc6adae6aa20876ae0283effa10e4","constraints":{"executionContext":"node"},"contract":["formatValue returns formatted string representations for objects and primitives","formatObject safely inspects circular data structures without throwing","supports depth option to limit inspection depth of nested structures","supports quoteStyle option for choosing single or double string quotes","supports maxStringLength option to truncate strings exceeding maximum length"],"goal":"verify pkg:npm/object-inspect@1.13.4","kind":"HOW","packages":["pkg:npm/object-inspect@1.13.4"],"schemaVersion":1},"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/object-inspect@1.13.4"],"schemaVersion":1,"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-object-inspect",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-object-inspect",
      "version": "1.0.0",
      "dependencies": {
        "object-inspect": "1.13.4"
      }
    },
    "node_modules/object-inspect": {
      "version": "1.13.4",
      "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
      "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      },
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    }
  }
}
package.json
{
  "name": "sample-object-inspect",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of object-inspect",
  "main": "src/index.js",
  "dependencies": {
    "object-inspect": "1.13.4"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/object-inspect@1.13.4",
  "kind": "HOW",
  "packages": [
    "pkg:npm/object-inspect@1.13.4"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const inspect = require('object-inspect');

/**
 * Format a value or object using object-inspect with optional custom options.
 * @param {*} value - The value to inspect
 * @param {object} [options] - Options passed to object-inspect
 * @returns {string} Formatted string representation
 */
function formatValue(value, options) {
  return inspect(value, options);
}

/**
 * Format an object safely even with circular references or deep nesting.
 * @param {object} obj - Object to format safely
 * @param {object} [options] - Options
 * @returns {string} Formatted string representation
 */
function formatObject(obj, options = {}) {
  return inspect(obj, {
    depth: 5,
    ...options
  });
}

module.exports = {
  formatValue,
  formatObject,
  inspect
};
test/contract.mjs
import assert from 'node:assert';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const { formatValue, formatObject, inspect } = require('../src/index.js');

// 1. Export verification
assert.strictEqual(typeof inspect, 'function', 'inspect should be exported as a function');
assert.strictEqual(typeof formatValue, 'function', 'formatValue should be a function');
assert.strictEqual(typeof formatObject, 'function', 'formatObject should be a function');

// 2. Format primitive and object structures
const obj = { name: 'sample', count: 42, active: true };
const objFormatted = formatValue(obj);
assert.strictEqual(objFormatted, "{ name: 'sample', count: 42, active: true }");

const arr = [1, 2, 'three'];
assert.strictEqual(formatValue(arr), "[ 1, 2, 'three' ]");

// 3. Handle circular references safely without throwing
const circular = { id: 1 };
circular.self = circular;
const circularResult = formatObject(circular);
assert.strictEqual(circularResult, '{ id: 1, self: [Circular] }');

// 4. Respect depth option for nested structures
const deep = { level1: { level2: { level3: 'deepValue' } } };
const shallowResult = formatValue(deep, { depth: 1 });
assert.strictEqual(shallowResult, '{ level1: [Object] }');

// 5. Support quoteStyle and maxStringLength options
const doubleQuote = formatValue('hello world', { quoteStyle: 'double' });
assert.strictEqual(doubleQuote, '"hello world"');

const truncated = formatValue('supercalifragilistic', { maxStringLength: 5 });
assert.strictEqual(truncated, "'super'... 15 more characters");

console.log('Contract tests passed successfully.');

Seeder de origem

anônimo