CodeSampleX

샘플

minipass 3.3.6

검증된 샘플 — npm minipass 3.3.6. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: Minipass synchronous write and read operations handle string and…

sha256:1cd7f581e922c8f8edbc48a8c3cdb58235ec0e708d022927aa295e2cb01c7694

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

검증 실행 환경

환경 컨트랙트 단계 실행일
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-21

케이스

HOW
목표
verify pkg:npm/minipass@3.3.6
패키지
환경
node 22.23.2
생성일
2026-08-21T18:06:21Z

컨트랙트

  1. Minipass synchronous write and read operations handle string and buffer chunks with encoding conversion
  2. Minipass pipe forwards data between stream instances with automatic flow control and event forwarding
  3. Minipass objectMode preserves JavaScript objects without buffer coercion or serialization
  4. Minipass collect and concat asynchronously accumulate streamed chunks into arrays and strings
  5. Minipass promise resolves on stream completion and rejects on stream destruction with error
  6. Minipass pause and resume manage flowing state and buffer drained chunks

파일

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • 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/minipass@3.3.6
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/minipass@3.3.6
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - 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:384e28a77b381f7eab09644fb7897f0d36adf8f75cd425ecae12f8390e555567","constraints":{"executionContext":"node"},"contract":["Minipass synchronous write and read operations handle string and buffer chunks with encoding conversion","Minipass pipe forwards data between stream instances with automatic flow control and event forwarding","Minipass objectMode preserves JavaScript objects without buffer coercion or serialization","Minipass collect and concat asynchronously accumulate streamed chunks into arrays and strings","Minipass promise resolves on stream completion and rejects on stream destruction with error","Minipass pause and resume manage flowing state and buffer drained chunks"],"goal":"verify pkg:npm/minipass@3.3.6","kind":"HOW","packages":["pkg:npm/minipass@3.3.6"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/minipass@3.3.6"],"schemaVersion":1,"subject":"pkg:npm/minipass@3.3.6","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-minipass",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-minipass",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "minipass": "3.3.6"
      }
    },
    "node_modules/minipass": {
      "version": "3.3.6",
      "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz",
      "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==",
      "license": "ISC",
      "dependencies": {
        "yallist": "^4.0.0"
      },
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/yallist": {
      "version": "4.0.0",
      "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
      "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
      "license": "ISC"
    }
  }
}
package.json
{
  "name": "sample-minipass",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for minipass",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "minipass": "3.3.6"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/minipass@3.3.6",
  "kind": "HOW",
  "packages": [
    "pkg:npm/minipass@3.3.6"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const Minipass = require('minipass');

/**
 * Creates a standard Minipass stream with optional configuration.
 * @param {object} [options]
 * @returns {Minipass}
 */
function createStream(options) {
  return new Minipass(options);
}

/**
 * Pipes data from source stream to destination stream.
 * @param {Minipass} src
 * @param {Minipass} dest
 * @returns {Minipass}
 */
function pipeStream(src, dest) {
  return src.pipe(dest);
}

/**
 * Collects all chunks from a stream into an array.
 * @param {Minipass} stream
 * @returns {Promise<Array>}
 */
async function collectStream(stream) {
  return stream.collect();
}

/**
 * Concatenates all chunks from a stream into a single string or Buffer.
 * @param {Minipass} stream
 * @returns {Promise<string|Buffer>}
 */
async function concatStream(stream) {
  return stream.concat();
}

module.exports = {
  Minipass,
  createStream,
  pipeStream,
  collectStream,
  concatStream
};
test/contract.js
const assert = require('node:assert/strict');
const {
  Minipass,
  createStream,
  pipeStream,
  collectStream,
  concatStream
} = require('../src/index.js');

async function main() {
  // 1. Minipass synchronous write and read operations handle string and buffer chunks with encoding conversion
  {
    const stream = createStream({ encoding: 'utf8' });
    assert.equal(stream.encoding, 'utf8');
    assert.equal(stream.bufferLength, 0);

    stream.write(Buffer.from('hello '));
    stream.write('world');
    assert.equal(stream.bufferLength, 11);

    const chunk = stream.read();
    assert.equal(chunk, 'hello world');
    assert.equal(stream.bufferLength, 0);

    stream.end();
    assert.equal(stream.emittedEnd, true);
  }

  // 2. Minipass pipe forwards data between stream instances with automatic flow control and event forwarding
  {
    const src = createStream();
    const dest = createStream();
    pipeStream(src, dest);

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

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

    assert.equal(dest.emittedEnd, true);
    assert.equal(received.join(''), 'pipeline-data');
  }

  // 3. Minipass objectMode preserves JavaScript objects without buffer coercion or serialization
  {
    const stream = createStream({ objectMode: true });
    assert.equal(stream.objectMode, true);

    const payload1 = { id: 101, type: 'event' };
    const payload2 = { id: 102, type: 'metric' };

    stream.write(payload1);
    stream.write(payload2);
    stream.end();

    const items = [];
    for (const item of stream) {
      items.push(item);
    }
    assert.deepEqual(items, [payload1, payload2]);
  }

  // 4. Minipass collect and concat asynchronously accumulate streamed chunks into arrays and strings
  {
    const stream1 = createStream({ encoding: 'utf8' });
    stream1.write('chunk-1');
    stream1.write('chunk-2');
    stream1.end();
    const collected = await collectStream(stream1);
    assert.equal(collected.length, 2);
    assert.equal(collected[0], 'chunk-1');
    assert.equal(collected[1], 'chunk-2');
    assert.equal(collected.dataLength, 14);

    const stream2 = createStream({ encoding: 'utf8' });
    stream2.write('partA');
    stream2.write('partB');
    stream2.end();
    const concatenated = await concatStream(stream2);
    assert.equal(concatenated, 'partApartB');
  }

  // 5. Minipass promise resolves on stream completion and rejects on stream destruction with error
  {
    const stream1 = createStream();
    const p1 = stream1.promise();
    stream1.write('data');
    stream1.end();
    await p1;

    const stream2 = createStream();
    const p2 = stream2.promise();
    const failureErr = new Error('simulated failure');
    stream2.destroy(failureErr);
    await assert.rejects(p2, { message: 'simulated failure' });
  }

  // 6. Minipass pause and resume manage flowing state and buffer drained chunks
  {
    const stream = createStream({ encoding: 'utf8' });
    stream.pause();
    assert.equal(stream.paused, true);

    const chunks = [];
    stream.on('data', (chunk) => {
      chunks.push(chunk);
    });

    stream.write('delayed-content');
    assert.equal(chunks.length, 0);
    assert.equal(stream.bufferLength, 15);

    stream.resume();
    assert.equal(stream.paused, false);
    assert.equal(chunks.length, 1);
    assert.equal(chunks[0], 'delayed-content');
    assert.equal(stream.bufferLength, 0);

    stream.end();
  }

  console.log('Contract assertions passed.');
}

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

오리진 시더

익명