CodeSampleX

Ejemplo

pvutils 1.2.0: utilConcatBuf

Muestra verificada para npm pvutils 1.2.0: utilConcatBuf. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó.

sha256:d4f7fff63608a070c4a6ec53fd70599b2899eb11a0e428be839aa97dd2b57299

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado linux 24 · ubuntu · glibc 2.39 x64 npm

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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-06

Caso

HOW
Objetivo
verify pvutils.utilConcatBuf in pkg:npm/pvutils@1.2.0
Paquetes
Símbolos
  • pvutils.utilConcatBuf
Creado
2026-09-06T02:43:36Z

Contrato

  1. utilConcatBuf concatenates multiple ArrayBuffer instances into a single contiguous ArrayBuffer
  2. utilConcatBuf preserves byte ordering and element values across joined buffers
  3. utilConcatBuf returns an empty ArrayBuffer when invoked with zero arguments or empty buffers
  4. utilConcatBuf returns an equivalent ArrayBuffer when given a single buffer argument

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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 pvutils.utilConcatBuf in pkg:npm/pvutils@1.2.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/pvutils@1.2.0
Demonstrate these symbols/APIs:
  - pvutils.utilConcatBuf

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:c7edd3aefd5c095c454b060e29c5d0805fc4c8a2cc31f63c306e6da6b6f53e80","contract":["utilConcatBuf concatenates multiple ArrayBuffer instances into a single contiguous ArrayBuffer","utilConcatBuf preserves byte ordering and element values across joined buffers","utilConcatBuf returns an empty ArrayBuffer when invoked with zero arguments or empty buffers","utilConcatBuf returns an equivalent ArrayBuffer when given a single buffer argument"],"goal":"verify pvutils.utilConcatBuf in pkg:npm/pvutils@1.2.0","kind":"HOW","packages":["pkg:npm/pvutils@1.2.0"],"schemaVersion":1,"symbols":["pvutils.utilConcatBuf"]},"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/pvutils@1.2.0"],"schemaVersion":1,"subject":"pkg:npm/pvutils@1.2.0","symbols":["pvutils.utilConcatBuf"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-pvutils",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-pvutils",
      "version": "1.0.0",
      "dependencies": {
        "pvutils": "1.2.0"
      }
    },
    "node_modules/pvutils": {
      "version": "1.2.0",
      "resolved": "https://registry.npmjs.org/pvutils/-/pvutils-1.2.0.tgz",
      "integrity": "sha512-BbubeCEyTuQjVMakvJQ/Sxbc93F2pwmbsxONT/ZRrwU7Ua38d8unYTwXpTVLAKJ4BDuH9IGztCjQcd/N/39Dvg==",
      "license": "MIT",
      "engines": {
        "node": ">=16.0.0"
      }
    }
  }
}
package.json
{
  "name": "sample-pvutils",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of pvutils.utilConcatBuf",
  "type": "module",
  "main": "src/index.js",
  "dependencies": {
    "pvutils": "1.2.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pvutils.utilConcatBuf in pkg:npm/pvutils@1.2.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/pvutils@1.2.0"
  ],
  "symbols": [
    "pvutils.utilConcatBuf"
  ]
}
src/index.js
import { utilConcatBuf } from 'pvutils';

/**
 * Concatenate multiple ArrayBuffers into a single contiguous ArrayBuffer.
 * @param {...ArrayBuffer} buffers
 * @returns {ArrayBuffer}
 */
export function concatBuffers(...buffers) {
  return utilConcatBuf(...buffers);
}

export { utilConcatBuf };
test/contract.mjs
import assert from 'node:assert';
import { utilConcatBuf, concatBuffers } from '../src/index.js';

// 1. utilConcatBuf concatenates multiple ArrayBuffer instances into a single contiguous ArrayBuffer
{
  const buf1 = new Uint8Array([1, 2, 3]).buffer;
  const buf2 = new Uint8Array([4, 5]).buffer;
  const buf3 = new Uint8Array([6, 7, 8, 9]).buffer;
  const result = utilConcatBuf(buf1, buf2, buf3);

  assert.strictEqual(result instanceof ArrayBuffer, true);
  assert.strictEqual(result.byteLength, 9);
  assert.deepStrictEqual(Array.from(new Uint8Array(result)), [1, 2, 3, 4, 5, 6, 7, 8, 9]);
}

// 2. utilConcatBuf preserves byte ordering and element values across joined buffers
{
  const first = new Uint8Array([0xaa, 0xbb]).buffer;
  const second = new Uint8Array([0xcc, 0xdd, 0xee]).buffer;
  const merged = concatBuffers(first, second);

  assert.strictEqual(merged.byteLength, 5);
  const view = new Uint8Array(merged);
  assert.strictEqual(view[0], 0xaa);
  assert.strictEqual(view[1], 0xbb);
  assert.strictEqual(view[2], 0xcc);
  assert.strictEqual(view[3], 0xdd);
  assert.strictEqual(view[4], 0xee);
}

// 3. utilConcatBuf returns an empty ArrayBuffer when invoked with zero arguments or empty buffers
{
  const noArgs = utilConcatBuf();
  assert.strictEqual(noArgs instanceof ArrayBuffer, true);
  assert.strictEqual(noArgs.byteLength, 0);

  const emptyA = new ArrayBuffer(0);
  const emptyB = new ArrayBuffer(0);
  const emptyMerged = utilConcatBuf(emptyA, emptyB);
  assert.strictEqual(emptyMerged instanceof ArrayBuffer, true);
  assert.strictEqual(emptyMerged.byteLength, 0);
}

// 4. utilConcatBuf returns an equivalent ArrayBuffer when given a single buffer argument
{
  const single = new Uint8Array([42, 43, 44]).buffer;
  const result = utilConcatBuf(single);

  assert.strictEqual(result instanceof ArrayBuffer, true);
  assert.strictEqual(result.byteLength, 3);
  assert.deepStrictEqual(Array.from(new Uint8Array(result)), [42, 43, 44]);
}

console.log('All pvutils.utilConcatBuf contract assertions passed.');

Seeder de origen

anónimo