CodeSampleX

Beispiel

node-int64 0.4.0: prototype

Verifiziertes Beispiel für npm node-int64 0.4.0: prototype. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand.

sha256:b88d1e7059fb3c39357392de7179838ade71aacd4c1d0e671dc7494b5c9cb0b4

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 npm

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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

Fall

HOW
Ziel
verify node-int64.prototype in pkg:npm/node-int64@0.4.0
Pakete
Symbole
  • node-int64.prototype
Erstellt
2026-09-07T03:29:56Z

Contract

  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

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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

Ursprungs-Seeder

anonym