Beispiel
minizlib 3.1.0: compress and decompress data using minizlib Gzip and Gunzip streams
Verifiziertes Beispiel für npm minizlib 3.1.0: compress and decompress data using minizlib Gzip and Gunzip streams. Der Vertrag lief auf node 22 · linux…
sha256:867f0794653070fe38765517c2734750f5bea7d73308b69390c4ffc9efe03ffa
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
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
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@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-28 |
Fall
HOW- Ziel
- compress and decompress data using minizlib Gzip and Gunzip streams
- Pakete
- Symbole
-
- minizlib.Gunzip
- minizlib.Gzip
- Umgebung
- node 22.23.2
- Erstellt
- 2026-08-28T05:35:31Z
Contract
- Gzip and Gunzip classes are exported and instantiate stream instances extending Zlib
- Gzip synchronously compresses string or buffer into gzip formatted buffer with magic bytes 0x1f 0x8b
- Gunzip synchronously decompresses gzip buffer back to the original content
- Gzip piped into Gunzip processes data through stream pipeline asynchronously
- Gunzip raises ZlibError when consuming invalid or corrupted compressed input
Dateien
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
Quelltext
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: compress and decompress data using minizlib Gzip and Gunzip streams
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/minizlib@3.1.0
Demonstrate these symbols/APIs:
- minizlib.Gunzip
- minizlib.Gzip
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.
{"case":{"caseId":"case:sha256:ce021948e986b7e97843d5d9ab7d32dbd600772ddd521e7e2365da2fff5656e7","contract":["Gzip and Gunzip classes are exported and instantiate stream instances extending Zlib","Gzip synchronously compresses string or buffer into gzip formatted buffer with magic bytes 0x1f 0x8b","Gunzip synchronously decompresses gzip buffer back to the original content","Gzip piped into Gunzip processes data through stream pipeline asynchronously","Gunzip raises ZlibError when consuming invalid or corrupted compressed input"],"goal":"compress and decompress data using minizlib Gzip and Gunzip streams","kind":"HOW","packages":["pkg:npm/minizlib@3.1.0"],"schemaVersion":1,"symbols":["minizlib.Gunzip","minizlib.Gzip"]},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/minizlib@3.1.0"],"schemaVersion":1,"subject":"pkg:npm/minizlib@3.1.0","symbols":["minizlib.Gunzip","minizlib.Gzip"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-minizlib-gzip-gunzip",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-minizlib-gzip-gunzip",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"minizlib": "3.1.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"
}
},
"node_modules/minizlib": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.1.0.tgz",
"integrity": "sha512-KZxYo1BUkWD2TVFLr0MQoM8vUUigWD3LlD83a/75BqC+4qE0Hb1Vo5v1FgcfaNXvfXzr+5EhQ6ing/CaBijTlw==",
"license": "MIT",
"dependencies": {
"minipass": "^7.1.2"
},
"engines": {
"node": ">= 18"
}
}
}
}
{
"name": "sample-minizlib-gzip-gunzip",
"version": "1.0.0",
"private": true,
"type": "module",
"description": "Clean-room verification for minizlib Gzip and Gunzip streams",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"minizlib": "3.1.0"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "compress and decompress data using minizlib Gzip and Gunzip streams",
"kind": "HOW",
"packages": [
"pkg:npm/minizlib@3.1.0"
],
"symbols": [
"minizlib.Gunzip",
"minizlib.Gzip"
]
}
import { Gzip, Gunzip, Zlib, ZlibError } from 'minizlib';
/**
* Compresses data synchronously using minizlib Gzip.
* @param {string | Buffer} data
* @param {import('zlib').ZlibOptions} [options]
* @returns {Buffer}
*/
export function gzipSync(data, options) {
const zip = new Gzip(options);
zip.end(data);
return zip.read();
}
/**
* Decompresses gzip data synchronously using minizlib Gunzip.
* @param {Buffer} data
* @param {import('zlib').ZlibOptions} [options]
* @returns {Buffer}
*/
export function gunzipSync(data, options) {
const unzip = new Gunzip(options);
unzip.end(data);
return unzip.read();
}
/**
* Creates a configured Gzip compression stream.
* @param {import('zlib').ZlibOptions} [options]
* @returns {Gzip}
*/
export function createGzipStream(options) {
return new Gzip(options);
}
/**
* Creates a configured Gunzip decompression stream.
* @param {import('zlib').ZlibOptions} [options]
* @returns {Gunzip}
*/
export function createGunzipStream(options) {
return new Gunzip(options);
}
export { Gzip, Gunzip, Zlib, ZlibError };
import assert from 'node:assert/strict';
import {
Gzip,
Gunzip,
Zlib,
ZlibError,
gzipSync,
gunzipSync,
createGzipStream,
createGunzipStream,
} from '../src/index.js';
// 1. Gzip and Gunzip classes are exported and instantiate stream instances extending Zlib
assert.equal(typeof Gzip, 'function', 'Gzip must be a constructor function');
assert.equal(typeof Gunzip, 'function', 'Gunzip must be a constructor function');
const gzipInstance = new Gzip();
const gunzipInstance = new Gunzip();
assert.ok(gzipInstance instanceof Zlib, 'Gzip must inherit from Zlib');
assert.ok(gunzipInstance instanceof Zlib, 'Gunzip must inherit from Zlib');
// 2. Gzip synchronously compresses string or buffer into gzip formatted buffer with magic bytes 0x1f 0x8b
const sampleText = 'CodeSampleX minizlib stream contract verification payload 12345';
const compressedBuffer = gzipSync(sampleText);
assert.ok(Buffer.isBuffer(compressedBuffer), 'Compressed output must be a Buffer');
assert.ok(compressedBuffer.length > 0, 'Compressed output must not be empty');
assert.equal(compressedBuffer[0], 0x1f, 'Gzip magic byte 0 must be 0x1f');
assert.equal(compressedBuffer[1], 0x8b, 'Gzip magic byte 1 must be 0x8b');
// 3. Gunzip synchronously decompresses gzip buffer back to the original content
const decompressedBuffer = gunzipSync(compressedBuffer);
assert.ok(Buffer.isBuffer(decompressedBuffer), 'Decompressed output must be a Buffer');
assert.equal(decompressedBuffer.toString('utf8'), sampleText, 'Decompressed text must match original');
// 4. Gzip piped into Gunzip processes data through stream pipeline asynchronously
const zipStream = createGzipStream();
const unzipStream = createGunzipStream();
zipStream.pipe(unzipStream);
const receivedChunks = [];
unzipStream.on('data', chunk => receivedChunks.push(chunk));
await new Promise((resolve, reject) => {
unzipStream.on('end', () => {
const pipedResult = Buffer.concat(receivedChunks).toString('utf8');
assert.equal(pipedResult, sampleText, 'Stream piped result must match original payload');
resolve();
});
zipStream.on('error', reject);
unzipStream.on('error', reject);
zipStream.end(sampleText);
});
// 5. Gunzip raises ZlibError when consuming invalid or corrupted compressed input
let caughtError = null;
try {
gunzipSync(Buffer.from('not valid compressed gzip payload'));
} catch (err) {
caughtError = err;
}
assert.ok(caughtError !== null, 'Gunzip must throw an error on invalid compressed input');
assert.ok(caughtError instanceof Error, 'Thrown error must be an instance of Error');
assert.ok(
caughtError instanceof ZlibError || caughtError.code !== undefined || caughtError.message.length > 0,
'Error must have diagnostic details'
);
console.log('All minizlib contract assertions passed successfully.');
Ursprungs-Seeder
anonym