示例
readable-stream 2.3.8: Readable
已验证示例 — npm readable-stream 2.3.8: Readable. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: Readable stream emits queued chunks in flowing mode via…
sha256:ad3b14221e818ec5a0b3aba2846bacef99d5a5509df2805419534c51f8c65daf
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 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-23 |
案例
HOW- 目标
- verify readable-stream.Readable in pkg:npm/readable-stream@2.3.8
- 符号
-
- readable-stream.Readable
- 环境
- node 22.23.2
- 创建时间
- 2026-08-23T13:53:30Z
契约
- Readable stream emits queued chunks in flowing mode via data and end events
- Readable stream in paused mode supports synchronous read via readable events
- Readable stream with objectMode pushes and reads JavaScript objects
文件
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- 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: verify readable-stream.Readable in pkg:npm/readable-stream@2.3.8
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/readable-stream@2.3.8
Demonstrate these symbols/APIs:
- readable-stream.Readable
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:76315e97f860a9e864a1e58286611975ae900a7dc7d863ce4c4f68975e618b84","contract":["Readable stream emits queued chunks in flowing mode via data and end events","Readable stream in paused mode supports synchronous read via readable events","Readable stream with objectMode pushes and reads JavaScript objects"],"goal":"verify readable-stream.Readable in pkg:npm/readable-stream@2.3.8","kind":"HOW","packages":["pkg:npm/readable-stream@2.3.8"],"schemaVersion":1,"symbols":["readable-stream.Readable"]},"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/readable-stream@2.3.8"],"schemaVersion":1,"subject":"pkg:npm/readable-stream@2.3.8","symbols":["readable-stream.Readable"],"verifierAdapter":"node-typescript@1"}
const { Readable } = require('readable-stream');
/**
* Creates a Readable stream that emits items from an array.
*
* @param {Array<string|Buffer>} items
* @param {object} [options]
* @returns {Readable}
*/
function createReadableStream(items = [], options = {}) {
let index = 0;
return new Readable({
...options,
read() {
if (index < items.length) {
this.push(items[index++]);
} else {
this.push(null);
}
},
});
}
/**
* Creates an object-mode Readable stream that emits object items.
*
* @param {Array<any>} items
* @returns {Readable}
*/
function createObjectStream(items = []) {
return createReadableStream(items, { objectMode: true });
}
module.exports = {
Readable,
createReadableStream,
createObjectStream,
};
{
"name": "sample-readable-stream-readable",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-readable-stream-readable",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"readable-stream": "2.3.8"
}
},
"node_modules/core-util-is": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==",
"license": "MIT"
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"license": "ISC"
},
"node_modules/isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==",
"license": "MIT"
},
"node_modules/process-nextick-args": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
"license": "MIT"
},
"node_modules/readable-stream": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz",
"integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==",
"license": "MIT",
"dependencies": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~2.0.0",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.1.1",
"util-deprecate": "~1.0.1"
}
},
"node_modules/safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"license": "MIT"
},
"node_modules/string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"license": "MIT",
"dependencies": {
"safe-buffer": "~5.1.0"
}
},
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
"license": "MIT"
}
}
}
{
"name": "sample-readable-stream-readable",
"version": "1.0.0",
"description": "Verify readable-stream Readable stream implementation and data emission",
"main": "index.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"readable-stream": "2.3.8"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify readable-stream.Readable in pkg:npm/readable-stream@2.3.8",
"kind": "HOW",
"packages": [
"pkg:npm/readable-stream@2.3.8"
],
"symbols": [
"readable-stream.Readable"
]
}
const assert = require('node:assert');
const { Readable, createReadableStream, createObjectStream } = require('../index.js');
async function main() {
// 1. Readable stream emits queued chunks in flowing mode via data and end events
{
const stream = createReadableStream(['chunk1', 'chunk2', 'chunk3']);
const received = [];
stream.on('data', (chunk) => {
received.push(chunk.toString());
});
await new Promise((resolve, reject) => {
stream.on('end', resolve);
stream.on('error', reject);
});
assert.deepStrictEqual(received, ['chunk1', 'chunk2', 'chunk3']);
}
// 2. Readable stream in paused mode supports synchronous read via readable events
{
const stream = createReadableStream(['alpha', 'beta']);
const chunks = [];
await new Promise((resolve, reject) => {
stream.on('readable', () => {
let chunk;
while ((chunk = stream.read()) !== null) {
chunks.push(chunk.toString());
}
});
stream.on('end', resolve);
stream.on('error', reject);
});
assert.strictEqual(chunks.join(''), 'alphabeta');
}
// 3. Readable stream with objectMode pushes and reads JavaScript objects
{
const objects = [{ id: 1, name: 'first' }, { id: 2, name: 'second' }];
const stream = createObjectStream(objects);
const collected = [];
stream.on('data', (item) => {
collected.push(item);
});
await new Promise((resolve, reject) => {
stream.on('end', resolve);
stream.on('error', reject);
});
assert.deepStrictEqual(collected, objects);
}
console.log('Contract test passed successfully.');
}
main().catch((err) => {
console.error(err);
process.exit(1);
});
原始种子者
匿名