CodeSampleX

サンプル

unpipe 1.0.0

検証済みサンプル — npm unpipe 1.0.0. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: unpipe(stream) throws TypeError when argument stream is missing or…

sha256:f4a1ec262a24dcd3bb0cdb42c70e084c3c23bfdbb1afc0035e56f61567ea77b7

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

実行証拠

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

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 linux 24 · ubuntu · glibc 2.39 x64 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/unpipe@1.0.0
パッケージ
作成日
2026-08-20T14:07:13Z

コントラクト

  1. unpipe(stream) throws TypeError when argument stream is missing or null
  2. unpipe(stream) calls stream.unpipe() to detach stream from its destination
  3. unpipe(stream) stops data flow between readable stream and destination writable stream
  4. unpipe(stream) disconnects readable stream from multiple destination streams simultaneously
  5. unpipe(stream) safely handles stream objects without unpipe method

ファイル

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

ソースアーティファクトをダウンロード (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/unpipe@1.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/unpipe@1.0.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:c09433db90162206dcb98ec207cee8e93a13de614c35ef11810b644b9cc964ab","contract":["unpipe(stream) throws TypeError when argument stream is missing or null","unpipe(stream) calls stream.unpipe() to detach stream from its destination","unpipe(stream) stops data flow between readable stream and destination writable stream","unpipe(stream) disconnects readable stream from multiple destination streams simultaneously","unpipe(stream) safely handles stream objects without unpipe method"],"goal":"verify pkg:npm/unpipe@1.0.0","kind":"HOW","packages":["pkg:npm/unpipe@1.0.0"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"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/unpipe@1.0.0"],"schemaVersion":1,"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "csx-sample-unpipe",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "csx-sample-unpipe",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "unpipe": "1.0.0"
      }
    },
    "node_modules/unpipe": {
      "version": "1.0.0",
      "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
      "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.8"
      }
    }
  }
}
package.json
{
  "name": "csx-sample-unpipe",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification for unpipe",
  "main": "test/contract.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "unpipe": "1.0.0"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/unpipe@1.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/unpipe@1.0.0"
  ]
}
test/contract.js
const assert = require('assert');
const { PassThrough } = require('stream');
const unpipe = require('unpipe');

async function runTests() {
  // Test 1: unpipe(stream) throws TypeError when argument stream is missing or null
  {
    assert.throws(
      () => unpipe(),
      /^TypeError: argument stream is required$/,
      'unpipe() without arguments should throw TypeError'
    );
    assert.throws(
      () => unpipe(null),
      /^TypeError: argument stream is required$/,
      'unpipe(null) should throw TypeError'
    );
    assert.throws(
      () => unpipe(undefined),
      /^TypeError: argument stream is required$/,
      'unpipe(undefined) should throw TypeError'
    );
  }

  // Test 2: unpipe(stream) calls stream.unpipe() to detach stream from its destination
  {
    let unpipeCalled = false;
    const fakeStream = {
      unpipe() {
        unpipeCalled = true;
      }
    };
    unpipe(fakeStream);
    assert.strictEqual(unpipeCalled, true, 'unpipe should invoke stream.unpipe()');
  }

  // Test 3: unpipe(stream) stops data flow between readable stream and destination writable stream
  await new Promise((resolve, reject) => {
    const src = new PassThrough();
    const dest = new PassThrough();

    const receivedChunks = [];
    dest.on('data', (chunk) => {
      receivedChunks.push(chunk.toString());
    });

    src.pipe(dest);
    src.write('first-chunk');

    // Unpipe source from destination
    unpipe(src);

    src.write('second-chunk');
    src.end();

    setImmediate(() => {
      try {
        assert.deepStrictEqual(receivedChunks, ['first-chunk'], 'destination should not receive data after unpipe');
        resolve();
      } catch (err) {
        reject(err);
      }
    });
  });

  // Test 4: unpipe(stream) disconnects readable stream from multiple destination streams simultaneously
  await new Promise((resolve, reject) => {
    const src = new PassThrough();
    const dest1 = new PassThrough();
    const dest2 = new PassThrough();

    const chunks1 = [];
    const chunks2 = [];

    dest1.on('data', (chunk) => chunks1.push(chunk.toString()));
    dest2.on('data', (chunk) => chunks2.push(chunk.toString()));

    src.pipe(dest1);
    src.pipe(dest2);

    src.write('initial-data');

    unpipe(src);

    src.write('subsequent-data');
    src.end();

    setImmediate(() => {
      try {
        assert.deepStrictEqual(chunks1, ['initial-data'], 'dest1 should only receive initial data');
        assert.deepStrictEqual(chunks2, ['initial-data'], 'dest2 should only receive initial data');
        resolve();
      } catch (err) {
        reject(err);
      }
    });
  });

  // Test 5: unpipe(stream) safely handles stream objects without unpipe method
  {
    const noUnpipeStream = {
      listeners(event) {
        return [];
      }
    };
    assert.doesNotThrow(() => {
      unpipe(noUnpipeStream);
    }, 'unpipe should safely handle stream without unpipe method');
  }

  console.log('All unpipe contract assertions passed successfully.');
}

runTests().catch((err) => {
  console.error('Contract test failed:', err);
  process.exit(1);
});

オリジンシーダー

匿名