CodeSampleX

Ejemplo

minipass 3.3.6

Muestra verificada para npm minipass 3.3.6. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: Minipass synchronous write and read…

sha256:1cd7f581e922c8f8edbc48a8c3cdb58235ec0e708d022927aa295e2cb01c7694

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 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Entornos de las ejecuciones de verificación

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

Caso

HOW
Objetivo
verify pkg:npm/minipass@3.3.6
Paquetes
Entorno
node 22.23.2
Creado
2026-08-21T18:06:21Z

Contrato

  1. Minipass synchronous write and read operations handle string and buffer chunks with encoding conversion
  2. Minipass pipe forwards data between stream instances with automatic flow control and event forwarding
  3. Minipass objectMode preserves JavaScript objects without buffer coercion or serialization
  4. Minipass collect and concat asynchronously accumulate streamed chunks into arrays and strings
  5. Minipass promise resolves on stream completion and rejects on stream destruction with error
  6. Minipass pause and resume manage flowing state and buffer drained chunks

Archivos

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

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 pkg:npm/minipass@3.3.6
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/minipass@3.3.6
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:384e28a77b381f7eab09644fb7897f0d36adf8f75cd425ecae12f8390e555567","constraints":{"executionContext":"node"},"contract":["Minipass synchronous write and read operations handle string and buffer chunks with encoding conversion","Minipass pipe forwards data between stream instances with automatic flow control and event forwarding","Minipass objectMode preserves JavaScript objects without buffer coercion or serialization","Minipass collect and concat asynchronously accumulate streamed chunks into arrays and strings","Minipass promise resolves on stream completion and rejects on stream destruction with error","Minipass pause and resume manage flowing state and buffer drained chunks"],"goal":"verify pkg:npm/minipass@3.3.6","kind":"HOW","packages":["pkg:npm/minipass@3.3.6"],"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/minipass@3.3.6"],"schemaVersion":1,"subject":"pkg:npm/minipass@3.3.6","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-minipass",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-minipass",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "minipass": "3.3.6"
      }
    },
    "node_modules/minipass": {
      "version": "3.3.6",
      "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz",
      "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==",
      "license": "ISC",
      "dependencies": {
        "yallist": "^4.0.0"
      },
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/yallist": {
      "version": "4.0.0",
      "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
      "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
      "license": "ISC"
    }
  }
}
package.json
{
  "name": "sample-minipass",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for minipass",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "minipass": "3.3.6"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/minipass@3.3.6",
  "kind": "HOW",
  "packages": [
    "pkg:npm/minipass@3.3.6"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const Minipass = require('minipass');

/**
 * Creates a standard Minipass stream with optional configuration.
 * @param {object} [options]
 * @returns {Minipass}
 */
function createStream(options) {
  return new Minipass(options);
}

/**
 * Pipes data from source stream to destination stream.
 * @param {Minipass} src
 * @param {Minipass} dest
 * @returns {Minipass}
 */
function pipeStream(src, dest) {
  return src.pipe(dest);
}

/**
 * Collects all chunks from a stream into an array.
 * @param {Minipass} stream
 * @returns {Promise<Array>}
 */
async function collectStream(stream) {
  return stream.collect();
}

/**
 * Concatenates all chunks from a stream into a single string or Buffer.
 * @param {Minipass} stream
 * @returns {Promise<string|Buffer>}
 */
async function concatStream(stream) {
  return stream.concat();
}

module.exports = {
  Minipass,
  createStream,
  pipeStream,
  collectStream,
  concatStream
};
test/contract.js
const assert = require('node:assert/strict');
const {
  Minipass,
  createStream,
  pipeStream,
  collectStream,
  concatStream
} = require('../src/index.js');

async function main() {
  // 1. Minipass synchronous write and read operations handle string and buffer chunks with encoding conversion
  {
    const stream = createStream({ encoding: 'utf8' });
    assert.equal(stream.encoding, 'utf8');
    assert.equal(stream.bufferLength, 0);

    stream.write(Buffer.from('hello '));
    stream.write('world');
    assert.equal(stream.bufferLength, 11);

    const chunk = stream.read();
    assert.equal(chunk, 'hello world');
    assert.equal(stream.bufferLength, 0);

    stream.end();
    assert.equal(stream.emittedEnd, true);
  }

  // 2. Minipass pipe forwards data between stream instances with automatic flow control and event forwarding
  {
    const src = createStream();
    const dest = createStream();
    pipeStream(src, dest);

    const received = [];
    dest.on('data', (chunk) => {
      received.push(chunk.toString());
    });

    src.write('pipeline-');
    src.write('data');
    src.end();

    assert.equal(dest.emittedEnd, true);
    assert.equal(received.join(''), 'pipeline-data');
  }

  // 3. Minipass objectMode preserves JavaScript objects without buffer coercion or serialization
  {
    const stream = createStream({ objectMode: true });
    assert.equal(stream.objectMode, true);

    const payload1 = { id: 101, type: 'event' };
    const payload2 = { id: 102, type: 'metric' };

    stream.write(payload1);
    stream.write(payload2);
    stream.end();

    const items = [];
    for (const item of stream) {
      items.push(item);
    }
    assert.deepEqual(items, [payload1, payload2]);
  }

  // 4. Minipass collect and concat asynchronously accumulate streamed chunks into arrays and strings
  {
    const stream1 = createStream({ encoding: 'utf8' });
    stream1.write('chunk-1');
    stream1.write('chunk-2');
    stream1.end();
    const collected = await collectStream(stream1);
    assert.equal(collected.length, 2);
    assert.equal(collected[0], 'chunk-1');
    assert.equal(collected[1], 'chunk-2');
    assert.equal(collected.dataLength, 14);

    const stream2 = createStream({ encoding: 'utf8' });
    stream2.write('partA');
    stream2.write('partB');
    stream2.end();
    const concatenated = await concatStream(stream2);
    assert.equal(concatenated, 'partApartB');
  }

  // 5. Minipass promise resolves on stream completion and rejects on stream destruction with error
  {
    const stream1 = createStream();
    const p1 = stream1.promise();
    stream1.write('data');
    stream1.end();
    await p1;

    const stream2 = createStream();
    const p2 = stream2.promise();
    const failureErr = new Error('simulated failure');
    stream2.destroy(failureErr);
    await assert.rejects(p2, { message: 'simulated failure' });
  }

  // 6. Minipass pause and resume manage flowing state and buffer drained chunks
  {
    const stream = createStream({ encoding: 'utf8' });
    stream.pause();
    assert.equal(stream.paused, true);

    const chunks = [];
    stream.on('data', (chunk) => {
      chunks.push(chunk);
    });

    stream.write('delayed-content');
    assert.equal(chunks.length, 0);
    assert.equal(stream.bufferLength, 15);

    stream.resume();
    assert.equal(stream.paused, false);
    assert.equal(chunks.length, 1);
    assert.equal(chunks[0], 'delayed-content');
    assert.equal(stream.bufferLength, 0);

    stream.end();
  }

  console.log('Contract assertions passed.');
}

main().catch((err) => {
  console.error(err);
  process.exit(1);
});

Seeder de origen

anónimo