CodeSampleX

Exemple

combined-stream 1.0.8

Échantillon vérifié pour npm combined-stream 1.0.8. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.

sha256:a7ee5b1675019a6b39b893dd20f0e8483c795078536a161da97ceff6cf5fbb29

Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré. Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes. MIT-0

Preuves d'exécution

L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.

Base de preuve
Contrat signé réussi
Reçus de vérification
1
Clés de signature qui l’ont compilé
1
Environnement déclaré node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
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

Cas

HOW
Objectif
verify pkg:npm/combined-stream@1.0.8
Paquets
Environnement
node 22.23.2
Créé
2026-08-20T20:26:29Z

Contrat

  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

Fichiers

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

Télécharger l’artefact source (tar.gz)

Code source

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 d'origine

anonyme