CodeSampleX

Beispiel

@isaacs/fs-minipass 4.0.1

Verifiziertes Beispiel für npm @isaacs/fs-minipass 4.0.1. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand.

sha256:641c296a56c62f60769e6302dce97562cbbb86c2e6ef21a9d8d476c6680ff406

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 npm

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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

Fall

HOW
Ziel
verify pkg:npm/%40isaacs/fs-minipass@4.0.1
Pakete
Erstellt
2026-08-21T12:15:01Z

Contract

  1. ReadStream asynchronously reads file contents as a Minipass stream
  2. ReadStreamSync synchronously reads file data into buffers
  3. WriteStream asynchronously writes data to a target file
  4. WriteStreamSync synchronously writes data to a destination file
  5. ReadStream and WriteStream support autoClose and custom read size configurations

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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/%40isaacs/fs-minipass@4.0.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40isaacs/fs-minipass@4.0.1

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:c37c3e15c15e408c945e4d89ed9d6382125d478d70115c825fa0b4708068c097","contract":["ReadStream asynchronously reads file contents as a Minipass stream","ReadStreamSync synchronously reads file data into buffers","WriteStream asynchronously writes data to a target file","WriteStreamSync synchronously writes data to a destination file","ReadStream and WriteStream support autoClose and custom read size configurations"],"goal":"verify pkg:npm/%40isaacs/fs-minipass@4.0.1","kind":"HOW","packages":["pkg:npm/%40isaacs/fs-minipass@4.0.1"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"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/%40isaacs/fs-minipass@4.0.1"],"schemaVersion":1,"subject":"pkg:npm/%40isaacs/fs-minipass@4.0.1","verifierAdapter":"node-typescript@1"}
index.mjs
import {
  ReadStream,
  ReadStreamSync,
  WriteStream,
  WriteStreamSync,
} from '@isaacs/fs-minipass';

/**
 * Creates an asynchronous ReadStream for reading from a file path.
 *
 * @param {string} path - File path to read
 * @param {object} [options] - Stream configuration options
 * @returns {ReadStream}
 */
export function createReadStream(path, options = {}) {
  return new ReadStream(path, options);
}

/**
 * Creates a synchronous ReadStream for reading from a file path.
 *
 * @param {string} path - File path to read
 * @param {object} [options] - Stream configuration options
 * @returns {ReadStreamSync}
 */
export function createReadStreamSync(path, options = {}) {
  return new ReadStreamSync(path, options);
}

/**
 * Creates an asynchronous WriteStream for writing to a file path.
 *
 * @param {string} path - Target file path
 * @param {object} [options] - Stream configuration options
 * @returns {WriteStream}
 */
export function createWriteStream(path, options = {}) {
  return new WriteStream(path, options);
}

/**
 * Creates a synchronous WriteStream for writing to a file path.
 *
 * @param {string} path - Target file path
 * @param {object} [options] - Stream configuration options
 * @returns {WriteStreamSync}
 */
export function createWriteStreamSync(path, options = {}) {
  return new WriteStreamSync(path, options);
}

/**
 * Synchronously writes data to a file using WriteStreamSync.
 *
 * @param {string} path - Target file path
 * @param {string | Buffer} data - Content to write
 */
export function writeFileSync(path, data) {
  const stream = new WriteStreamSync(path);
  stream.write(data);
  stream.end();
}

/**
 * Synchronously reads the full content of a file using ReadStreamSync.
 *
 * @param {string} path - File path to read
 * @returns {Buffer | null}
 */
export function readFileSync(path) {
  const stream = new ReadStreamSync(path);
  return stream.read();
}

export { ReadStream, ReadStreamSync, WriteStream, WriteStreamSync };
package-lock.json
{
  "name": "sample-fs-minipass",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-fs-minipass",
      "version": "1.0.0",
      "dependencies": {
        "@isaacs/fs-minipass": "4.0.1"
      }
    },
    "node_modules/@isaacs/fs-minipass": {
      "version": "4.0.1",
      "resolved": "https://registry.npmjs.org/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz",
      "integrity": "sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==",
      "license": "ISC",
      "dependencies": {
        "minipass": "^7.0.4"
      },
      "engines": {
        "node": ">=18.0.0"
      }
    },
    "node_modules/minipass": {
      "version": "7.1.3",
      "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz",
      "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==",
      "license": "BlueOak-1.0.0",
      "engines": {
        "node": ">=16 || 14 >=14.17"
      }
    }
  }
}
package.json
{
  "name": "sample-fs-minipass",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "@isaacs/fs-minipass": "4.0.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40isaacs/fs-minipass@4.0.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40isaacs/fs-minipass@4.0.1"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import {
  ReadStream,
  ReadStreamSync,
  WriteStream,
  WriteStreamSync,
  createReadStream,
  createReadStreamSync,
  createWriteStream,
  createWriteStreamSync,
  writeFileSync,
  readFileSync,
} from '../index.mjs';

const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'fs-minipass-contract-'));

try {
  const syncFilePath = path.join(tempDir, 'sync-test.txt');
  const asyncFilePath = path.join(tempDir, 'async-test.txt');

  // 1. WriteStreamSync synchronously writes data to a destination file
  {
    const wsSync = new WriteStreamSync(syncFilePath);
    assert.equal(wsSync.path, syncFilePath);
    wsSync.write('Header: ');
    wsSync.write(Buffer.from('Synchronous content.'));
    wsSync.end();

    const diskContent = fs.readFileSync(syncFilePath, 'utf8');
    assert.equal(diskContent, 'Header: Synchronous content.');
  }

  // 2. ReadStreamSync synchronously reads file data into buffers
  {
    const rsSync = new ReadStreamSync(syncFilePath);
    assert.equal(rsSync.path, syncFilePath);
    const chunk = rsSync.read();
    assert.ok(Buffer.isBuffer(chunk));
    assert.equal(chunk.toString('utf8'), 'Header: Synchronous content.');

    const helperChunk = readFileSync(syncFilePath);
    assert.equal(helperChunk.toString('utf8'), 'Header: Synchronous content.');
  }

  // 3. WriteStream asynchronously writes data to a target file
  {
    await new Promise((resolve, reject) => {
      const ws = new WriteStream(asyncFilePath);
      assert.equal(ws.path, asyncFilePath);
      ws.on('error', reject);
      ws.on('finish', resolve);
      ws.write('Async stream line 1\n');
      ws.end(Buffer.from('Async stream line 2\n'));
    });

    const written = fs.readFileSync(asyncFilePath, 'utf8');
    assert.equal(written, 'Async stream line 1\nAsync stream line 2\n');
  }

  // 4. ReadStream asynchronously reads file contents as a Minipass stream
  {
    const rs = new ReadStream(asyncFilePath);
    assert.equal(rs.path, asyncFilePath);
    const chunks = await rs.collect();
    const result = Buffer.concat(chunks).toString('utf8');
    assert.equal(result, 'Async stream line 1\nAsync stream line 2\n');
  }

  // 5. ReadStream and WriteStream support autoClose and custom read size configurations
  {
    const sizedFilePath = path.join(tempDir, 'sized.txt');
    writeFileSync(sizedFilePath, '0123456789ABCDEF');

    const rsChunked = createReadStream(sizedFilePath, { readSize: 4, autoClose: true });
    const collectedChunks = [];
    for await (const chunk of rsChunked) {
      collectedChunks.push(chunk);
    }
    assert.equal(collectedChunks.length, 4);
    assert.equal(Buffer.concat(collectedChunks).toString('utf8'), '0123456789ABCDEF');
  }

  console.log('Contract passed');
} finally {
  fs.rmSync(tempDir, { recursive: true, force: true });
}

Ursprungs-Seeder

anonym