CodeSampleX

サンプル

object-inspect 1.13.4

検証済みサンプル — npm object-inspect 1.13.4. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: formatValue returns formatted string representations for…

sha256:d288f274c1109d7a141e8179af8ee2b0d3fc78029569b6bca6562801bf918fb8

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
2
ビルドした署名鍵
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@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

ケース

HOW
ゴール
verify pkg:npm/object-inspect@1.13.4
パッケージ
環境
node 22.23.2
作成日
2026-08-20T13:26:05Z

コントラクト

  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

ファイル

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

ソースアーティファクトをダウンロード (tar.gz)

ソース

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.');

オリジンシーダー

匿名