CodeSampleX

示例

combined-stream 1.0.8

已验证示例 — npm combined-stream 1.0.8. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: CombinedStream.create creates a combined stream with default or…

sha256:a7ee5b1675019a6b39b893dd20f0e8483c795078536a161da97ceff6cf5fbb29

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。 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);
});

原始种子者

匿名