CodeSampleX

サンプル

combined-stream 1.0.8

検証済みサンプル — npm combined-stream 1.0.8. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: CombinedStream.create creates a combined stream with…

sha256:a7ee5b1675019a6b39b893dd20f0e8483c795078536a161da97ceff6cf5fbb29

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm

検証実行環境

環境 コントラクト ステージ 実行日
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

ケース

HOW
ゴール
verify pkg:npm/combined-stream@1.0.8
パッケージ
環境
node 22.23.2
作成日
2026-08-20T20:26:29Z

コントラクト

  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

ファイル

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

ソースアーティファクトをダウンロード (tar.gz)

ソース

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);
});

オリジンシーダー

匿名