Exemplo
duplexer2 0.1.4: DuplexWrapper
Amostra verificada para npm duplexer2 0.1.4: DuplexWrapper. O contrato rodou em node 22 · linux debian/x64 · docker e passou: new…
sha256:016520ed30b4dd684e594afca8b1eae2d95809523bf553a6ef5bcdc125a7ba73
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux 24 · ubuntu · glibc 2.39 x64 npm
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-05 |
Caso
HOW- Objetivo
- verify duplexer2.DuplexWrapper in pkg:npm/duplexer2@0.1.4
- Pacotes
- Símbolos
-
- duplexer2.DuplexWrapper
- Criado
- 2026-09-05T19:13:39Z
Contrato
- new duplexer2.DuplexWrapper(writable, readable) returns a DuplexWrapper instance combining writable and readable streams
- DuplexWrapper exposes _writable and _readable properties referencing the underlying streams
- new duplexer2.DuplexWrapper(options, writable, readable) supports stream options such as objectMode
- writing data to DuplexWrapper forwards chunks to the underlying writable stream
- reading data from DuplexWrapper pulls chunks from the underlying readable stream
- DuplexWrapper wraps legacy streams lacking a .read method into readable-stream Readable
- DuplexWrapper bubbles error events from writable stream to wrapper by default
- DuplexWrapper bubbles error events from readable stream to wrapper by default
- DuplexWrapper suppresses error bubbling when bubbleErrors option is false
- ending DuplexWrapper automatically ends the underlying writable stream
- finishing the underlying writable stream automatically ends DuplexWrapper
Arquivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.js
Código-fonte
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 duplexer2.DuplexWrapper in pkg:npm/duplexer2@0.1.4
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/duplexer2@0.1.4
Demonstrate these symbols/APIs:
- duplexer2.DuplexWrapper
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:51b8918b59984f5568fef71d66c9b03fe9796d5eee87918439b9d7ea63895573","contract":["new duplexer2.DuplexWrapper(writable, readable) returns a DuplexWrapper instance combining writable and readable streams","DuplexWrapper exposes _writable and _readable properties referencing the underlying streams","new duplexer2.DuplexWrapper(options, writable, readable) supports stream options such as objectMode","writing data to DuplexWrapper forwards chunks to the underlying writable stream","reading data from DuplexWrapper pulls chunks from the underlying readable stream","DuplexWrapper wraps legacy streams lacking a .read method into readable-stream Readable","DuplexWrapper bubbles error events from writable stream to wrapper by default","DuplexWrapper bubbles error events from readable stream to wrapper by default","DuplexWrapper suppresses error bubbling when bubbleErrors option is false","ending DuplexWrapper automatically ends the underlying writable stream","finishing the underlying writable stream automatically ends DuplexWrapper"],"goal":"verify duplexer2.DuplexWrapper in pkg:npm/duplexer2@0.1.4","kind":"HOW","packages":["pkg:npm/duplexer2@0.1.4"],"schemaVersion":1,"symbols":["duplexer2.DuplexWrapper"]},"contractCommand":["node","test/contract.js"],"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/duplexer2@0.1.4"],"schemaVersion":1,"subject":"pkg:npm/duplexer2@0.1.4","symbols":["duplexer2.DuplexWrapper"],"verifierAdapter":"node-typescript@1"}
{
"name": "csx-sample-duplexer2-duplexwrapper",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "csx-sample-duplexer2-duplexwrapper",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"duplexer2": "0.1.4"
}
},
"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/duplexer2": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz",
"integrity": "sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA==",
"license": "BSD-3-Clause",
"dependencies": {
"readable-stream": "^2.0.2"
}
},
"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": "csx-sample-duplexer2-duplexwrapper",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification for duplexer2.DuplexWrapper",
"main": "test/contract.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"duplexer2": "0.1.4"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify duplexer2.DuplexWrapper in pkg:npm/duplexer2@0.1.4",
"kind": "HOW",
"packages": [
"pkg:npm/duplexer2@0.1.4"
],
"symbols": [
"duplexer2.DuplexWrapper"
]
}
const assert = require('node:assert/strict');
const { EventEmitter } = require('node:events');
const { PassThrough, Readable, Writable } = require('node:stream');
const duplexer2 = require('duplexer2');
const stream = require('readable-stream');
async function runTests() {
// Test 1: new duplexer2.DuplexWrapper(writable, readable) returns a DuplexWrapper instance combining writable and readable streams
{
const writable = new PassThrough();
const readable = new PassThrough();
const wrapper = new duplexer2.DuplexWrapper(writable, readable);
assert(wrapper instanceof duplexer2.DuplexWrapper, 'wrapper should be an instance of DuplexWrapper');
assert(wrapper instanceof stream.Duplex, 'wrapper should inherit from stream.Duplex');
assert.strictEqual(typeof wrapper.pipe, 'function', 'wrapper should have pipe method');
assert.strictEqual(typeof wrapper.write, 'function', 'wrapper should have write method');
assert.strictEqual(typeof wrapper.read, 'function', 'wrapper should have read method');
}
// Test 2: DuplexWrapper exposes _writable and _readable properties referencing the underlying streams
{
const writable = new PassThrough();
const readable = new PassThrough();
const wrapper = new duplexer2.DuplexWrapper(writable, readable);
assert.strictEqual(wrapper._writable, writable, '_writable should match passed writable');
assert.strictEqual(wrapper._readable, readable, '_readable should match passed readable');
}
// Test 3: new duplexer2.DuplexWrapper(options, writable, readable) supports stream options such as objectMode
await new Promise((resolve, reject) => {
const receivedObjects = [];
const writable = new Writable({
objectMode: true,
write(chunk, encoding, callback) {
receivedObjects.push(chunk);
callback();
}
});
const readable = new Readable({
objectMode: true,
read() {
this.push({ id: 101, status: 'active' });
this.push({ id: 102, status: 'complete' });
this.push(null);
}
});
const wrapper = new duplexer2.DuplexWrapper({ objectMode: true }, writable, readable);
const outputObjects = [];
wrapper.on('data', (chunk) => {
outputObjects.push(chunk);
});
wrapper.write({ task: 'alpha' });
wrapper.write({ task: 'beta' });
wrapper.end();
wrapper.on('end', () => {
try {
assert.deepStrictEqual(receivedObjects, [{ task: 'alpha' }, { task: 'beta' }]);
assert.deepStrictEqual(outputObjects, [
{ id: 101, status: 'active' },
{ id: 102, status: 'complete' }
]);
resolve();
} catch (err) {
reject(err);
}
});
});
// Test 4: writing data to DuplexWrapper forwards chunks to the underlying writable stream
await new Promise((resolve, reject) => {
const written = [];
const writable = new Writable({
write(chunk, encoding, callback) {
written.push(chunk.toString());
callback();
}
});
const readable = new PassThrough();
const wrapper = new duplexer2.DuplexWrapper(writable, readable);
wrapper.write('packet1');
wrapper.write('packet2');
wrapper.end();
wrapper.on('finish', () => {
try {
assert.deepStrictEqual(written, ['packet1', 'packet2']);
resolve();
} catch (err) {
reject(err);
}
});
});
// Test 5: reading data from DuplexWrapper pulls chunks from the underlying readable stream
await new Promise((resolve, reject) => {
const chunks = [];
const writable = new PassThrough();
const readable = Readable.from(['entryA', 'entryB', 'entryC']);
const wrapper = new duplexer2.DuplexWrapper(writable, readable);
wrapper.on('data', (chunk) => {
chunks.push(chunk.toString());
});
wrapper.on('end', () => {
try {
assert.deepStrictEqual(chunks, ['entryA', 'entryB', 'entryC']);
resolve();
} catch (err) {
reject(err);
}
});
});
// Test 6: DuplexWrapper wraps legacy streams lacking a .read method into readable-stream Readable
{
const legacy = new EventEmitter();
legacy.pipe = function() {};
legacy.pause = function() {};
legacy.resume = function() {};
const writable = new PassThrough();
const wrapper = new duplexer2.DuplexWrapper(writable, legacy);
assert.strictEqual(typeof wrapper._readable.read, 'function', 'legacy stream should be wrapped in Readable');
}
// Test 7: DuplexWrapper bubbles error events from writable stream to wrapper by default
await new Promise((resolve, reject) => {
const writable = new PassThrough();
const readable = new PassThrough();
const wrapper = new duplexer2.DuplexWrapper(writable, readable);
const testError = new Error('error on writable');
wrapper.on('error', (err) => {
try {
assert.strictEqual(err, testError);
resolve();
} catch (e) {
reject(e);
}
});
writable.emit('error', testError);
});
// Test 8: DuplexWrapper bubbles error events from readable stream to wrapper by default
await new Promise((resolve, reject) => {
const writable = new PassThrough();
const readable = new PassThrough();
const wrapper = new duplexer2.DuplexWrapper(writable, readable);
const testError = new Error('error on readable');
wrapper.on('error', (err) => {
try {
assert.strictEqual(err, testError);
resolve();
} catch (e) {
reject(e);
}
});
readable.emit('error', testError);
});
// Test 9: DuplexWrapper suppresses error bubbling when bubbleErrors option is false
await new Promise((resolve, reject) => {
const writable = new PassThrough();
const readable = new PassThrough();
const wrapper = new duplexer2.DuplexWrapper({ bubbleErrors: false }, writable, readable);
let wrapperErrored = false;
wrapper.on('error', () => {
wrapperErrored = true;
});
writable.on('error', () => {});
readable.on('error', () => {});
writable.emit('error', new Error('suppressed writable error'));
readable.emit('error', new Error('suppressed readable error'));
setImmediate(() => {
try {
assert.strictEqual(wrapperErrored, false, 'wrapper should not receive error when bubbleErrors is false');
resolve();
} catch (err) {
reject(err);
}
});
});
// Test 10: ending DuplexWrapper automatically ends the underlying writable stream
await new Promise((resolve, reject) => {
const writable = new PassThrough();
const readable = new PassThrough();
const wrapper = new duplexer2.DuplexWrapper(writable, readable);
let writableFinished = false;
writable.on('finish', () => {
writableFinished = true;
});
wrapper.end();
setImmediate(() => {
try {
assert.strictEqual(writableFinished, true, 'writable should finish when wrapper is ended');
resolve();
} catch (err) {
reject(err);
}
});
});
// Test 11: finishing the underlying writable stream automatically ends DuplexWrapper
await new Promise((resolve, reject) => {
const writable = new PassThrough();
const readable = new PassThrough();
const wrapper = new duplexer2.DuplexWrapper(writable, readable);
let wrapperFinished = false;
wrapper.on('finish', () => {
wrapperFinished = true;
});
writable.end();
setImmediate(() => {
try {
assert.strictEqual(wrapperFinished, true, 'wrapper should finish when writable is finished');
resolve();
} catch (err) {
reject(err);
}
});
});
console.log('All duplexer2.DuplexWrapper contract assertions passed successfully.');
}
runTests().catch((err) => {
console.error('Contract test failed:', err);
process.exit(1);
});
Seeder de origem
anônimo