CodeSampleX

샘플

loupe 3.2.1

검증된 샘플 — npm loupe 3.2.1. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: inspect formats primitive values including strings, numbers, booleans…

sha256:4a4c68b2f6f9a388fb401a3f15388e84b442aec062a5ebe619be0d1b79afc385

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

실행 증거

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

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

검증 실행 환경

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

케이스

HOW
목표
verify pkg:npm/loupe@3.2.1
패키지
생성일
2026-08-21T03:30:11Z

컨트랙트

  1. inspect formats primitive values including strings, numbers, booleans, null, undefined, BigInt, and Symbols
  2. inspect formats structured objects, arrays, Sets, and Maps
  3. inspect detects circular references and formats them with [Circular] placeholders
  4. inspect formats RegExp patterns and Error objects
  5. inspect supports configuration options such as truncate length and ANSI color formatting
  6. custom symbol enables user-defined custom inspection methods on objects
  7. registerConstructor registers custom inspector functions for specific class constructors
  8. registerStringTag registers custom inspector functions matching Symbol.toStringTag values

파일

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.mjs
  • 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/loupe@3.2.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/loupe@3.2.1

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:9423f73d91cfd26b5fe3e0886210c7bbb3a53650288b40f7b3dbc429bca67e5d","contract":["inspect formats primitive values including strings, numbers, booleans, null, undefined, BigInt, and Symbols","inspect formats structured objects, arrays, Sets, and Maps","inspect detects circular references and formats them with [Circular] placeholders","inspect formats RegExp patterns and Error objects","inspect supports configuration options such as truncate length and ANSI color formatting","custom symbol enables user-defined custom inspection methods on objects","registerConstructor registers custom inspector functions for specific class constructors","registerStringTag registers custom inspector functions matching Symbol.toStringTag values"],"goal":"verify pkg:npm/loupe@3.2.1","kind":"HOW","packages":["pkg:npm/loupe@3.2.1"],"schemaVersion":1},"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/loupe@3.2.1"],"schemaVersion":1,"subject":"pkg:npm/loupe@3.2.1","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "verify-loupe",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "verify-loupe",
      "version": "1.0.0",
      "dependencies": {
        "loupe": "3.2.1"
      }
    },
    "node_modules/loupe": {
      "version": "3.2.1",
      "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz",
      "integrity": "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "verify-loupe",
  "version": "1.0.0",
  "type": "module",
  "dependencies": {
    "loupe": "3.2.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/loupe@3.2.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/loupe@3.2.1"
  ]
}
src/index.mjs
import { inspect, custom, registerConstructor, registerStringTag } from 'loupe';

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

export { inspect, custom, registerConstructor, registerStringTag };
export default inspect;
test/contract.mjs
import assert from 'node:assert';
import inspect, { custom, registerConstructor, registerStringTag } from '../src/index.mjs';

// 1. Primitive formatting
assert.strictEqual(inspect(null), 'null', 'inspect must format null correctly');
assert.strictEqual(inspect(undefined), 'undefined', 'inspect must format undefined correctly');
assert.strictEqual(inspect(42), '42', 'inspect must format numbers correctly');
assert.strictEqual(inspect('hello'), "'hello'", 'inspect must format strings with quotes');
assert.strictEqual(inspect(true), 'true', 'inspect must format boolean true correctly');
assert.strictEqual(inspect(false), 'false', 'inspect must format boolean false correctly');
assert.strictEqual(inspect(100n), '100n', 'inspect must format BigInt with n suffix');
assert.strictEqual(inspect(Symbol('test')), 'Symbol(test)', 'inspect must format Symbol correctly');

// 2. Structured objects, arrays, Sets, and Maps
assert.strictEqual(inspect([1, 2, 3]), '[ 1, 2, 3 ]', 'inspect must format arrays correctly');
assert.strictEqual(inspect({ a: 1, b: 'two' }), "{ a: 1, b: 'two' }", 'inspect must format object properties correctly');
assert.strictEqual(inspect(new Set([1, 2])), 'Set{ 1, 2 }', 'inspect must format Set elements');
assert.strictEqual(inspect(new Map([['key', 'val']])), "Map{ 'key' => 'val' }", 'inspect must format Map entries');

// 3. Circular reference detection
const circular = { name: 'cycle' };
circular.self = circular;
assert.strictEqual(inspect(circular), "{ name: 'cycle', self: [Circular] }", 'inspect must detect circular references and print [Circular]');

// 4. Built-ins: RegExp, Date, Error
assert.strictEqual(inspect(/^abc$/i), '/^abc$/i', 'inspect must format RegExp literals');
const testError = new Error('loupe test error');
assert.ok(inspect(testError).includes('Error: loupe test error'), 'inspect must format Error objects with message');

// 5. Options: truncate and colors
const longText = 'a very long string that should be truncated by loupe';
const truncated = inspect(longText, { truncate: 15 });
assert.ok(truncated.length <= 15, 'truncate option must limit string length');
assert.ok(truncated.includes('…'), 'truncated string must contain ellipsis');

const colored = inspect(123, { colors: true });
assert.ok(colored.includes('\x1B['), 'colors option must apply ANSI escape codes');

// 6. Custom inspect symbol
class Box {
  constructor(val) {
    this.val = val;
  }
  [custom]() {
    return `<Box: ${this.val}>`;
  }
}
assert.strictEqual(inspect(new Box(42)), '<Box: 42>', 'inspect must use custom inspect symbol method');
assert.strictEqual(inspect(new Box(42), { customInspect: false }), 'Box{ val: 42 }', 'customInspect: false must bypass custom inspect method');

// 7. registerConstructor
class SpecialWidget {
  constructor(id) {
    this.id = id;
  }
}
const regCtorResult = registerConstructor(SpecialWidget, (val) => `Widget#${val.id}`);
assert.strictEqual(regCtorResult, true, 'registerConstructor must return true on successful registration');
assert.strictEqual(inspect(new SpecialWidget(99)), 'Widget#99', 'registered constructor inspector must format instances');

// 8. registerStringTag
class CustomTagged {
  get [Symbol.toStringTag]() {
    return 'CustomWidgetTag';
  }
}
const regTagResult = registerStringTag('CustomWidgetTag', () => '<CustomTaggedInstance>');
assert.strictEqual(regTagResult, true, 'registerStringTag must return true on successful registration');
assert.strictEqual(inspect(new CustomTagged()), '<CustomTaggedInstance>', 'registered string tag inspector must format instances');

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

오리진 시더

익명