CodeSampleX

샘플

node-int64 0.4.0: prototype

검증된 샘플 — npm node-int64 0.4.0: prototype. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: Int64.prototype.setValue updates the 64-bit integer…

sha256:b88d1e7059fb3c39357392de7179838ade71aacd4c1d0e671dc7494b5c9cb0b4

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

실행 증거

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

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

검증 실행 환경

환경 컨트랙트 단계 실행일
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 node-int64.prototype in pkg:npm/node-int64@0.4.0
패키지
심벌
  • node-int64.prototype
생성일
2026-09-07T03:29:56Z

컨트랙트

  1. Int64.prototype.setValue updates the 64-bit integer from number, string, or hi-lo bit pairs
  2. Int64.prototype._2scomp performs in-place two's complement negation on the internal buffer
  3. Int64.prototype.valueOf converts the Int64 instance to a primitive JavaScript number
  4. Int64.prototype.toString returns decimal or radix-formatted string representation
  5. Int64.prototype.toOctetString formats the 8 internal bytes as hexadecimal octets with optional separator
  6. Int64.prototype.toBuffer returns an 8-byte Buffer copy or raw internal buffer reference
  7. Int64.prototype.copy copies the 8 bytes into a target Buffer at a specified offset
  8. Int64.prototype.compare performs signed 64-bit comparisons across positive and negative values
  9. Int64.prototype.equals verifies equality between identical Int64 values
  10. Int64.prototype.inspect produces formatted string containing decimal value and spaced hex octets

파일

  • PROMPT.md
  • csx.json
  • index.mjs
  • package-lock.json
  • package.json
  • spec.json
  • 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 node-int64.prototype in pkg:npm/node-int64@0.4.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/node-int64@0.4.0
Demonstrate these symbols/APIs:
  - node-int64.prototype

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:b22a0576aab7e6bb97d14f2938669ae349ea1dbe55ad422bf3cfcdebb97b2e5f","contract":["Int64.prototype.setValue updates the 64-bit integer from number, string, or hi-lo bit pairs","Int64.prototype._2scomp performs in-place two's complement negation on the internal buffer","Int64.prototype.valueOf converts the Int64 instance to a primitive JavaScript number","Int64.prototype.toString returns decimal or radix-formatted string representation","Int64.prototype.toOctetString formats the 8 internal bytes as hexadecimal octets with optional separator","Int64.prototype.toBuffer returns an 8-byte Buffer copy or raw internal buffer reference","Int64.prototype.copy copies the 8 bytes into a target Buffer at a specified offset","Int64.prototype.compare performs signed 64-bit comparisons across positive and negative values","Int64.prototype.equals verifies equality between identical Int64 values","Int64.prototype.inspect produces formatted string containing decimal value and spaced hex octets"],"goal":"verify node-int64.prototype in pkg:npm/node-int64@0.4.0","kind":"HOW","packages":["pkg:npm/node-int64@0.4.0"],"schemaVersion":1,"symbols":["node-int64.prototype"]},"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/node-int64@0.4.0"],"schemaVersion":1,"subject":"pkg:npm/node-int64@0.4.0","symbols":["node-int64.prototype"],"verifierAdapter":"node-typescript@1"}
index.mjs
import Int64 from 'node-int64';

export function updateValue(int64, ...args) {
  int64.setValue(...args);
  return int64;
}

export function negateInPlace(int64) {
  int64._2scomp();
  return int64;
}

export function toPrimitiveNumber(int64) {
  return int64.valueOf();
}

export function formatString(int64, radix) {
  return int64.toString(radix);
}

export function formatOctets(int64, separator) {
  return int64.toOctetString(separator);
}

export function extractBuffer(int64, raw = false) {
  return int64.toBuffer(raw);
}

export function copyInto(int64, target, offset = 0) {
  int64.copy(target, offset);
  return target;
}

export function compareInstances(a, b) {
  return a.compare(b);
}

export function areEqual(a, b) {
  return a.equals(b);
}

export function formatInspect(int64) {
  return int64.inspect();
}

export { Int64 };
package-lock.json
{
  "name": "sample-node-int64-prototype",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-node-int64-prototype",
      "version": "1.0.0",
      "dependencies": {
        "node-int64": "0.4.0"
      }
    },
    "node_modules/node-int64": {
      "version": "0.4.0",
      "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
      "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-node-int64-prototype",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "node-int64": "0.4.0"
  },
  "scripts": {
    "test": "node test/contract.mjs"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify node-int64.prototype in pkg:npm/node-int64@0.4.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/node-int64@0.4.0"
  ],
  "symbols": [
    "node-int64.prototype"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import Int64 from 'node-int64';
import {
  updateValue,
  negateInPlace,
  toPrimitiveNumber,
  formatString,
  formatOctets,
  extractBuffer,
  copyInto,
  compareInstances,
  areEqual,
  formatInspect
} from '../index.mjs';

// 1. Int64.prototype.setValue updates the 64-bit integer from number, string, or hi-lo bit pairs
{
  const a = new Int64(0);
  updateValue(a, 42);
  assert.equal(a.toNumber(), 42);

  updateValue(a, '0x0102030405060708');
  assert.equal(a.toOctetString(), '0102030405060708');

  updateValue(a, 0x12345678, 0x9abcdef0);
  assert.equal(a.toOctetString(), '123456789abcdef0');
}

// 2. Int64.prototype._2scomp performs in-place two's complement negation on the internal buffer
{
  const b = new Int64(1);
  negateInPlace(b);
  assert.equal(b.toNumber(), -1);

  negateInPlace(b);
  assert.equal(b.toNumber(), 1);
}

// 3. Int64.prototype.valueOf converts the Int64 instance to a primitive JavaScript number
{
  const c = new Int64(100);
  assert.equal(toPrimitiveNumber(c), 100);
  assert.equal(+c, 100);
  assert.equal(c + 5, 105);
}

// 4. Int64.prototype.toString returns decimal or radix-formatted string representation
{
  const d = new Int64(255);
  assert.equal(formatString(d), '255');
  assert.equal(formatString(d, 16), 'ff');
  assert.equal(formatString(d, 2), '11111111');
}

// 5. Int64.prototype.toOctetString formats the 8 internal bytes as hexadecimal octets with optional separator
{
  const e = new Int64(0x01234567, 0x89abcdef);
  assert.equal(formatOctets(e), '0123456789abcdef');
  assert.equal(formatOctets(e, ':'), '01:23:45:67:89:ab:cd:ef');
  assert.equal(formatOctets(e, ' '), '01 23 45 67 89 ab cd ef');
}

// 6. Int64.prototype.toBuffer returns an 8-byte Buffer copy or raw internal buffer reference
{
  const f = new Int64(12345);
  const bufCopied = extractBuffer(f);
  assert.ok(Buffer.isBuffer(bufCopied));
  assert.equal(bufCopied.length, 8);
  assert.notEqual(bufCopied, f.buffer);

  const bufRaw = extractBuffer(f, true);
  assert.equal(bufRaw, f.buffer);
}

// 7. Int64.prototype.copy copies the 8 bytes into a target Buffer at a specified offset
{
  const f = new Int64(12345);
  const target = Buffer.alloc(16, 0);
  copyInto(f, target, 4);
  assert.equal(target.readUInt32BE(8), 12345);
  assert.equal(target[0], 0);
  assert.equal(target[3], 0);
}

// 8. Int64.prototype.compare performs signed 64-bit comparisons across positive and negative values
{
  const neg = new Int64(-10);
  const pos = new Int64(10);
  assert.ok(compareInstances(neg, pos) < 0);
  assert.ok(compareInstances(pos, neg) > 0);
  assert.equal(compareInstances(neg, new Int64(-10)), 0);
}

// 9. Int64.prototype.equals verifies equality between identical Int64 values
{
  const a = new Int64(500);
  const b = new Int64(500);
  const c = new Int64(600);
  assert.equal(areEqual(a, b), true);
  assert.equal(areEqual(a, c), false);
}

// 10. Int64.prototype.inspect produces formatted string containing decimal value and spaced hex octets
{
  const h = new Int64(256);
  assert.equal(formatInspect(h), '[Int64 value:256 octets:00 00 00 00 00 00 01 00]');
}

console.log('node-int64.prototype contract verified.');

오리진 시더

익명