CodeSampleX

샘플

object-inspect 1.14.0

검증된 샘플 — npm object-inspect 1.14.0. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: inspectValue formats primitives (-0, BigInt, null, undefined)…

sha256:cfcc140d3eff53517ff13ca25e6466ffa9d804409dd8c229586345eef1985711

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

검증 실행 환경

환경 컨트랙트 단계 실행일
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-11-22

케이스

HOW
목표
verify pkg:npm/object-inspect@1.14.0
패키지
환경
node 22.23.2
생성일
2026-11-22T01:09:12Z

컨트랙트

  1. inspectValue formats primitives (-0, BigInt, null, undefined), plain structures, and null-prototype objects
  2. inspectValue handles circular references as [Circular] without throwing
  3. depth limits nested object and array inspection to [Object] and [Array]
  4. quoteStyle selects single or double quotes and maxStringLength truncates strings with remaining character count
  5. maxCollectionLength truncates arrays, Sets, and Maps with remaining item counts
  6. numericSeparator formats numbers and BigInts with underscores and multilineStrings preserves literal newlines
  7. indent and breakLength control single-line versus indented multi-line formatting
  8. customInspect honors true, 'symbol', and false for legacy inspect() and util.inspect.custom
  9. invalid quoteStyle, maxStringLength, maxCollectionLength, indent, breakLength, and customInspect options throw TypeError

파일

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

소스 아티팩트 내려받기 (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.14.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/object-inspect@1.14.0
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:7785ed9641f8358722bdf1510520ca5fa4d9d9f7990ea62adfa11073360ea0bc","constraints":{"executionContext":"node"},"contract":["inspectValue formats primitives (-0, BigInt, null, undefined), plain structures, and null-prototype objects","inspectValue handles circular references as [Circular] without throwing","depth limits nested object and array inspection to [Object] and [Array]","quoteStyle selects single or double quotes and maxStringLength truncates strings with remaining character count","maxCollectionLength truncates arrays, Sets, and Maps with remaining item counts","numericSeparator formats numbers and BigInts with underscores and multilineStrings preserves literal newlines","indent and breakLength control single-line versus indented multi-line formatting","customInspect honors true, 'symbol', and false for legacy inspect() and util.inspect.custom","invalid quoteStyle, maxStringLength, maxCollectionLength, indent, breakLength, and customInspect options throw TypeError"],"goal":"verify pkg:npm/object-inspect@1.14.0","kind":"HOW","packages":["pkg:npm/object-inspect@1.14.0"],"schemaVersion":1},"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/object-inspect@1.14.0"],"schemaVersion":1,"subject":"pkg:npm/object-inspect@1.14.0","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "object-inspect-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "object-inspect-sample",
      "version": "1.0.0",
      "dependencies": {
        "object-inspect": "1.14.0"
      }
    },
    "node_modules/object-inspect": {
      "version": "1.14.0",
      "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.14.0.tgz",
      "integrity": "sha512-IVgHNlp/jwQX271+Xzoq9LZNTWXxZK+cEOrGBOBxXNbn7fapnZ+Ts6TVMgNOuAezwG2wdtnMX97tTPK6VEnuOQ==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      },
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    }
  }
}
package.json
{
  "name": "object-inspect-sample",
  "version": "1.0.0",
  "private": true,
  "description": "Minimal contract sample verifying object-inspect 1.14.0 in CommonJS on Node.js",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "object-inspect": "1.14.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/object-inspect@1.14.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/object-inspect@1.14.0"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
'use strict';

const inspect = require('object-inspect');

function inspectValue(value, options) {
  return inspect(value, options);
}

function inspectWithLimits(value, { depth, maxStringLength, maxCollectionLength, breakLength } = {}) {
  const options = {};
  if (depth !== undefined) {
    options.depth = depth;
  }
  if (maxStringLength !== undefined) {
    options.maxStringLength = maxStringLength;
  }
  if (maxCollectionLength !== undefined) {
    options.maxCollectionLength = maxCollectionLength;
  }
  if (breakLength !== undefined) {
    options.breakLength = breakLength;
  }
  return inspect(value, options);
}

module.exports = {
  inspectValue,
  inspectWithLimits,
};
test/contract.js
'use strict';

const assert = require('node:assert/strict');
const util = require('node:util');
const { inspectValue, inspectWithLimits } = require('../src/index.js');

// 1. Primitives, negative zero, BigInt, null-prototype objects, and nested plain structures
assert.equal(inspectValue(undefined), 'undefined');
assert.equal(inspectValue(null), 'null');
assert.equal(inspectValue(-0), '-0');
assert.equal(inspectValue(42n), '42n');
assert.equal(inspectValue({ a: 1, b: [2, 'x'] }), "{ a: 1, b: [ 2, 'x' ] }");
const nullProto = Object.assign(Object.create(null), { k: 'v' });
assert.equal(inspectValue(nullProto), "[Object: null prototype] { k: 'v' }");

// 2. Circular references render [Circular] without throwing
const circular = { name: 'node' };
circular.self = circular;
assert.equal(inspectValue(circular), "{ name: 'node', self: [Circular] }");

// 3. depth option bounds nested object and array expansion
assert.equal(
  inspectWithLimits({ a: { b: { c: 1 } } }, { depth: 1 }),
  '{ a: [Object] }'
);
assert.equal(
  inspectWithLimits([[1, 2]], { depth: 1 }),
  '[ [Array] ]'
);

// 4. quoteStyle and maxStringLength options
assert.equal(inspectValue('hello', { quoteStyle: 'double' }), '"hello"');
assert.equal(
  inspectWithLimits('abcdef', { maxStringLength: 3 }),
  "'abc'... 3 more characters"
);
assert.equal(
  inspectWithLimits('abcd', { maxStringLength: 3 }),
  "'abc'... 1 more character"
);

// 5. maxCollectionLength option truncates arrays, Sets, and Maps
assert.equal(
  inspectWithLimits([1, 2, 3, 4], { maxCollectionLength: 2 }),
  '[ 1, 2, ... 2 more items ]'
);
assert.equal(
  inspectWithLimits(new Set(['a', 'b', 'c']), { maxCollectionLength: 2 }),
  "Set (3) {'a', 'b', ... 1 more item}"
);
assert.equal(
  inspectWithLimits(new Map([['x', 1], ['y', 2], ['z', 3]]), { maxCollectionLength: 1 }),
  "Map (3) {'x' => 1, ... 2 more items}"
);

// 6. numericSeparator, multilineStrings, indent, and breakLength options
assert.equal(inspectValue(1000000, { numericSeparator: true }), '1_000_000');
assert.equal(inspectValue(1000000n, { numericSeparator: true }), '1_000_000n');
assert.equal(inspectValue('line1\nline2'), "'line1\\nline2'");
assert.equal(inspectValue('line1\nline2', { multilineStrings: true }), "'line1\nline2'");
assert.equal(
  inspectValue({ a: 1, b: 2 }, { indent: 2 }),
  '{\n  a: 1,\n  b: 2\n}'
);
assert.equal(
  inspectWithLimits({ alpha: 1, beta: 2, gamma: 3 }, { breakLength: 20 }),
  '{\n  alpha: 1,\n  beta: 2,\n  gamma: 3\n}'
);
assert.equal(
  inspectWithLimits({ alpha: 1, beta: 2, gamma: 3 }, { breakLength: Infinity }),
  '{ alpha: 1, beta: 2, gamma: 3 }'
);

// 7. customInspect supports true, 'symbol', and false
const withLegacyInspect = {
  value: 1,
  inspect() {
    return '<legacy>';
  },
};
const withSymbolInspect = {
  value: 2,
  [util.inspect.custom]() {
    return '<symbol>';
  },
};
assert.equal(inspectValue(withLegacyInspect), '<legacy>');
assert.equal(inspectValue(withLegacyInspect, { customInspect: 'symbol' }), '{ value: 1, inspect: [Function: inspect] }');
assert.equal(inspectValue(withSymbolInspect, { customInspect: 'symbol' }), '<symbol>');
assert.equal(
  inspectValue(withSymbolInspect, { customInspect: false }),
  '{ value: 2, [Symbol(nodejs.util.inspect.custom)]: [Function: [nodejs.util.inspect.custom]] }'
);

// 8. Invalid options throw TypeError
assert.throws(() => inspectValue('a', { quoteStyle: 'backtick' }), TypeError);
assert.throws(() => inspectValue('a', { maxStringLength: -1 }), TypeError);
assert.throws(() => inspectValue([1], { maxCollectionLength: 1.5 }), TypeError);
assert.throws(() => inspectValue({}, { indent: 0 }), TypeError);
assert.throws(() => inspectValue({}, { breakLength: -1 }), TypeError);
assert.throws(() => inspectValue({}, { customInspect: 'invalid' }), TypeError);

console.log('object-inspect@1.14.0 contract passed');

오리진 시더

익명