CodeSampleX

Ejemplo

combined-stream 1.0.8

Muestra verificada para npm combined-stream 1.0.8. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: CombinedStream.create creates a…

sha256:a7ee5b1675019a6b39b893dd20f0e8483c795078536a161da97ceff6cf5fbb29

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

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-20

Caso

HOW
Objetivo
verify pkg:npm/combined-stream@1.0.8
Paquetes
Entorno
node 22.23.2
Creado
2026-08-20T20:26:29Z

Contrato

  1. CombinedStream.create creates a combined stream with default or custom options
  2. CombinedStream.isStreamLike identifies stream-like objects and rejects primitive values
  3. CombinedStream.prototype.append chains and combines string, Buffer, and stream sources sequentially
  4. CombinedStream supports deferred stream resolution via callback functions
  5. CombinedStream.prototype.pipe streams combined data to a destination writable stream
  6. CombinedStream propagates error events from underlying streams
  7. CombinedStream.prototype.destroy resets internal stream state and emits close

Archivos

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

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/combined-stream@1.0.8
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/combined-stream@1.0.8
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - 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:f9a5ea5c2518e2ee304b19d811f6f21a9b0eb4eae68708a61f51e0f1b3f79890","constraints":{"executionContext":"node"},"contract":["CombinedStream.create creates a combined stream with default or custom options","CombinedStream.isStreamLike identifies stream-like objects and rejects primitive values","CombinedStream.prototype.append chains and combines string, Buffer, and stream sources sequentially","CombinedStream supports deferred stream resolution via callback functions","CombinedStream.prototype.pipe streams combined data to a destination writable stream","CombinedStream propagates error events from underlying streams","CombinedStream.prototype.destroy resets internal stream state and emits close"],"goal":"verify pkg:npm/combined-stream@1.0.8","kind":"HOW","packages":["pkg:npm/combined-stream@1.0.8"],"schemaVersion":1},"contractCommand":["node","test/contract.cjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/combined-stream@1.0.8"],"schemaVersion":1,"subject":"pkg:npm/combined-stream@1.0.8","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "combined-stream-verification",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "combined-stream-verification",
      "version": "1.0.0",
      "dependencies": {
        "combined-stream": "1.0.8"
      }
    },
    "node_modules/combined-stream": {
      "version": "1.0.8",
      "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
      "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
      "license": "MIT",
      "dependencies": {
        "delayed-stream": "~1.0.0"
      },
      "engines": {
        "node": ">= 0.8"
      }
    },
    "node_modules/delayed-stream": {
      "version": "1.0.0",
      "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
      "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
      "license": "MIT",
      "engines": {
        "node": ">=0.4.0"
      }
    }
  }
}
package.json
{
  "name": "combined-stream-verification",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification for combined-stream",
  "dependencies": {
    "combined-stream": "1.0.8"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/combined-stream@1.0.8",
  "kind": "HOW",
  "packages": [
    "pkg:npm/combined-stream@1.0.8"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "runtime": "node@22.23.2"
  }
}
test/contract.cjs
const assert = require('node:assert');
const { PassThrough, Writable } = require('node:stream');
const CombinedStream = require('combined-stream');

async function test() {
  // 1. CombinedStream.create creates a combined stream with default or custom options
  const defaultStream = CombinedStream.create();
  assert.strictEqual(defaultStream.maxDataSize, 2097152);
  assert.strictEqual(defaultStream.pauseStreams, true);

  const customStream = CombinedStream.create({ maxDataSize: 1024, pauseStreams: false });
  assert.strictEqual(customStream.maxDataSize, 1024);
  assert.strictEqual(customStream.pauseStreams, false);

  // 2. CombinedStream.isStreamLike identifies stream-like objects and rejects primitive values
  assert.strictEqual(CombinedStream.isStreamLike(new PassThrough()), true);
  assert.strictEqual(CombinedStream.isStreamLike({ pipe: () => {} }), true);
  assert.strictEqual(CombinedStream.isStreamLike('string'), false);
  assert.strictEqual(CombinedStream.isStreamLike(Buffer.from('buf')), false);
  assert.strictEqual(CombinedStream.isStreamLike(123), false);
  assert.strictEqual(CombinedStream.isStreamLike(true), false);
  assert.strictEqual(CombinedStream.isStreamLike(() => {}), false);

  // 3. CombinedStream.prototype.append chains and combines string, Buffer, and stream sources sequentially
  const cs = CombinedStream.create();
  const s1 = new PassThrough();
  const s2 = new PassThrough();
  const res = cs
    .append('header:')
    .append(Buffer.from('body:'))
    .append(s1)
    .append(s2);
  assert.strictEqual(res, cs);

  const chunks = [];
  cs.on('data', chunk => chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)));

  const finished = new Promise(resolve => cs.on('end', resolve));
  cs.resume();

  s1.write('stream1:');
  s1.end();
  s2.write('stream2');
  s2.end();

  await finished;
  assert.strictEqual(Buffer.concat(chunks).toString('utf8'), 'header:body:stream1:stream2');

  // 4. CombinedStream supports deferred stream resolution via callback functions
  const deferredCS = CombinedStream.create();
  deferredCS.append(next => {
    const pt = new PassThrough();
    pt.end('lazy-content');
    next(pt);
  });
  let deferredResult = '';
  deferredCS.on('data', chunk => { deferredResult += chunk.toString(); });
  const deferredFinished = new Promise(resolve => deferredCS.on('end', resolve));
  deferredCS.resume();
  await deferredFinished;
  assert.strictEqual(deferredResult, 'lazy-content');

  // 5. CombinedStream.prototype.pipe streams combined data to a destination writable stream
  const pipeCS = CombinedStream.create();
  pipeCS.append('chunk1-');
  pipeCS.append('chunk2');

  let pipedData = '';
  const dest = new Writable({
    write(chunk, encoding, callback) {
      pipedData += chunk.toString();
      callback();
    }
  });

  await new Promise(resolve => {
    dest.on('finish', resolve);
    pipeCS.pipe(dest);
  });
  assert.strictEqual(pipedData, 'chunk1-chunk2');

  // 6. CombinedStream propagates error events from underlying streams
  const errCS = CombinedStream.create();
  const faultyStream = new PassThrough();
  errCS.append(faultyStream);

  const errPromise = new Promise((resolve) => {
    errCS.on('error', err => resolve(err));
  });
  errCS.resume();

  faultyStream.emit('error', new Error('stream failure'));
  const caughtError = await errPromise;
  assert.strictEqual(caughtError.message, 'stream failure');

  // 7. CombinedStream.prototype.destroy resets internal stream state and emits close
  const destroyCS = CombinedStream.create();
  destroyCS.append('some-data');
  let closeEmitted = false;
  destroyCS.on('close', () => { closeEmitted = true; });
  destroyCS.destroy();
  assert.strictEqual(closeEmitted, true);
  assert.strictEqual(destroyCS.writable, false);

  console.log('Contract passed');
}

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

Seeder de origen

anónimo