示例
minizlib 3.1.0: compress and decompress data using minizlib Gzip and Gunzip streams
已验证示例 — npm minizlib 3.1.0: compress and decompress data using minizlib Gzip and Gunzip streams. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过.
sha256:867f0794653070fe38765517c2734750f5bea7d73308b69390c4ffc9efe03ffa
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
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@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-28 |
案例
HOW- 目标
- compress and decompress data using minizlib Gzip and Gunzip streams
- 符号
-
- minizlib.Gunzip
- minizlib.Gzip
- 环境
- node 22.23.2
- 创建时间
- 2026-08-28T05:35:31Z
契约
- 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
文件
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
源代码
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.');
原始种子者
匿名