CodeSampleX

Ejemplo

get-stream 5.2.0

Muestra verificada para npm get-stream 5.2.0. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: getStream returns a Promise that resolves…

sha256:a5c7bcc1657ef9a20bab71970777d5683dbd81bb1164ebb13b8a7540445dd04b

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 alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-23

Caso

HOW
Objetivo
verify pkg:npm/get-stream@5.2.0
Paquetes
Creado
2026-08-23T08:26:40Z

Contrato

  1. getStream returns a Promise that resolves to the full string contents of a stream
  2. getStream.buffer returns a Promise that resolves to a Buffer with concatenated stream chunks
  3. getStream.array returns a Promise that resolves to an array of items for an object-mode stream
  4. getStream with maxBuffer option rejects with getStream.MaxBufferError when stream data exceeds limit
  5. getStream rejects when the readable stream emits an error event

Archivos

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • 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 pkg:npm/get-stream@5.2.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/get-stream@5.2.0

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:0b76b2cb26337aeff3b4a227758006d35b2b0f9c372dbc451cede33a9acb9e83","contract":["getStream returns a Promise that resolves to the full string contents of a stream","getStream.buffer returns a Promise that resolves to a Buffer with concatenated stream chunks","getStream.array returns a Promise that resolves to an array of items for an object-mode stream","getStream with maxBuffer option rejects with getStream.MaxBufferError when stream data exceeds limit","getStream rejects when the readable stream emits an error event"],"goal":"verify pkg:npm/get-stream@5.2.0","kind":"HOW","packages":["pkg:npm/get-stream@5.2.0"],"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/get-stream@5.2.0"],"schemaVersion":1,"subject":"pkg:npm/get-stream@5.2.0","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "verify-get-stream",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "verify-get-stream",
      "version": "1.0.0",
      "dependencies": {
        "get-stream": "5.2.0"
      }
    },
    "node_modules/end-of-stream": {
      "version": "1.4.5",
      "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz",
      "integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==",
      "license": "MIT",
      "dependencies": {
        "once": "^1.4.0"
      }
    },
    "node_modules/get-stream": {
      "version": "5.2.0",
      "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz",
      "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==",
      "license": "MIT",
      "dependencies": {
        "pump": "^3.0.0"
      },
      "engines": {
        "node": ">=8"
      },
      "funding": {
        "url": "https://github.com/sponsors/sindresorhus"
      }
    },
    "node_modules/once": {
      "version": "1.4.0",
      "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
      "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
      "license": "ISC",
      "dependencies": {
        "wrappy": "1"
      }
    },
    "node_modules/pump": {
      "version": "3.0.4",
      "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.4.tgz",
      "integrity": "sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==",
      "license": "MIT",
      "dependencies": {
        "end-of-stream": "^1.1.0",
        "once": "^1.3.1"
      }
    },
    "node_modules/wrappy": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
      "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
      "license": "ISC"
    }
  }
}
package.json
{
  "name": "verify-get-stream",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "get-stream": "5.2.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/get-stream@5.2.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/get-stream@5.2.0"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { Readable } from 'node:stream';
import getStream from 'get-stream';

// 1. getStream returns a Promise that resolves to the full string contents of a stream
{
  const stream = Readable.from(['hello', ' ', 'world']);
  const result = await getStream(stream);
  assert.equal(typeof result, 'string');
  assert.equal(result, 'hello world');
}

// 2. getStream.buffer returns a Promise that resolves to a Buffer with concatenated stream chunks
{
  const chunk1 = Buffer.from('hello');
  const chunk2 = Buffer.from(' world');
  const stream = Readable.from([chunk1, chunk2]);
  const result = await getStream.buffer(stream);
  assert.ok(Buffer.isBuffer(result));
  assert.equal(result.toString('utf8'), 'hello world');
}

// 3. getStream.array returns a Promise that resolves to an array of items for an object-mode stream
{
  const items = [{ id: 1 }, { id: 2 }, { id: 3 }];
  const stream = Readable.from(items);
  const result = await getStream.array(stream);
  assert.ok(Array.isArray(result));
  assert.deepEqual(result, items);
}

// 4. getStream with maxBuffer option rejects with getStream.MaxBufferError when stream data exceeds limit
{
  const stream = Readable.from(['abcdef', '123456']);
  let caught = null;
  try {
    await getStream(stream, { maxBuffer: 5 });
  } catch (error) {
    caught = error;
  }
  assert.ok(caught instanceof getStream.MaxBufferError);
  assert.equal(caught.name, 'MaxBufferError');
}

// 5. getStream rejects when the readable stream emits an error event
{
  const stream = new Readable({
    read() {
      this.destroy(new Error('stream read failure'));
    }
  });
  let caught = null;
  try {
    await getStream(stream);
  } catch (error) {
    caught = error;
  }
  assert.ok(caught instanceof Error);
  assert.equal(caught.message, 'stream read failure');
}

console.log('Contract verification passed for get-stream');

Seeder de origen

anónimo