Ejemplo
bare-events 2.9.1: forward
Muestra verificada para npm bare-events 2.9.1: forward. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: EventEmitter.forward lazily…
sha256:a6921eef221f69725a418b05291831ddda3601210e544fc676498aec363b8851
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 2
- Claves de firma que lo compilaron
- 1
Entorno declarado
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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-26 |
| 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-07 |
Caso
HOW- Objetivo
- verify bare-events.forward in pkg:npm/bare-events@2.9.1
- Paquetes
- Símbolos
-
- bare-events.forward
- Entorno
- node 22.23.2
- Creado
- 2026-08-26T11:34:11Z
Contrato
- EventEmitter.forward lazily attaches a listener to the source emitter only when a listener is registered on the destination emitter
- forwarded events emitted on the source emitter are received by listeners on the destination emitter with original arguments
- multiple listeners on the destination emitter share a single forwarding listener on the source emitter
- removing all listeners for an event on the destination emitter detaches the forwarding listener from the source emitter
- forward supports an array of multiple event names managed independently
- forward accepts an optional custom emit function in options to intercept forwarded events
Archivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Código fuente
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 bare-events.forward in pkg:npm/bare-events@2.9.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/bare-events@2.9.1
Demonstrate these symbols/APIs:
- bare-events.forward
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:f12170e3edc0da2c6b5618d4a0150806ec0933f5604727d16bcf976c3e4d923f","constraints":{"executionContext":"node"},"contract":["EventEmitter.forward lazily attaches a listener to the source emitter only when a listener is registered on the destination emitter","forwarded events emitted on the source emitter are received by listeners on the destination emitter with original arguments","multiple listeners on the destination emitter share a single forwarding listener on the source emitter","removing all listeners for an event on the destination emitter detaches the forwarding listener from the source emitter","forward supports an array of multiple event names managed independently","forward accepts an optional custom emit function in options to intercept forwarded events"],"goal":"verify bare-events.forward in pkg:npm/bare-events@2.9.1","kind":"HOW","packages":["pkg:npm/bare-events@2.9.1"],"schemaVersion":1,"symbols":["bare-events.forward"]},"contractCommand":["node","test/contract.mjs"],"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/bare-events@2.9.1"],"schemaVersion":1,"subject":"pkg:npm/bare-events@2.9.1","symbols":["bare-events.forward"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-bare-events-forward",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-bare-events-forward",
"version": "1.0.0",
"dependencies": {
"bare-events": "2.9.1"
}
},
"node_modules/bare-events": {
"version": "2.9.1",
"resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.9.1.tgz",
"integrity": "sha512-Z0oHEHAFDZkffN8Qc39zNZjQlMDkPJRyyyZieU1VH7u8c5S+qHZ2S8ixdKIAxEjfHO7FJxXmJWgteOghVanIsg==",
"license": "Apache-2.0",
"peerDependencies": {
"bare-abort-controller": "*"
},
"peerDependenciesMeta": {
"bare-abort-controller": {
"optional": true
}
}
}
}
}
{
"name": "sample-bare-events-forward",
"version": "1.0.0",
"type": "module",
"private": true,
"dependencies": {
"bare-events": "2.9.1"
}
}
{
"schemaVersion": 1,
"goal": "verify bare-events.forward in pkg:npm/bare-events@2.9.1",
"kind": "HOW",
"packages": [
"pkg:npm/bare-events@2.9.1"
],
"symbols": [
"bare-events.forward"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert/strict';
import EventEmitter from 'bare-events';
// 1. EventEmitter.forward lazily attaches a listener to the source emitter only when a listener is registered on the destination emitter
{
const src = new EventEmitter();
const dest = new EventEmitter();
EventEmitter.forward(src, dest, 'eventA');
assert.equal(src.listenerCount('eventA'), 0);
assert.equal(dest.listenerCount('eventA'), 0);
const handler = () => {};
dest.on('eventA', handler);
assert.equal(src.listenerCount('eventA'), 1);
assert.equal(dest.listenerCount('eventA'), 1);
}
// 2. forwarded events emitted on the source emitter are received by listeners on the destination emitter with original arguments
{
const src = new EventEmitter();
const dest = new EventEmitter();
EventEmitter.forward(src, dest, 'message');
const received = [];
dest.on('message', (arg1, arg2) => {
received.push({ arg1, arg2 });
});
const emitted = src.emit('message', 'hello', 42);
assert.equal(emitted, true);
assert.deepEqual(received, [{ arg1: 'hello', arg2: 42 }]);
}
// 3. multiple listeners on the destination emitter share a single forwarding listener on the source emitter
{
const src = new EventEmitter();
const dest = new EventEmitter();
EventEmitter.forward(src, dest, 'shared');
const list1 = [];
const list2 = [];
dest.on('shared', (val) => list1.push(val));
dest.on('shared', (val) => list2.push(val));
assert.equal(dest.listenerCount('shared'), 2);
assert.equal(src.listenerCount('shared'), 1);
src.emit('shared', 'broadcast');
assert.deepEqual(list1, ['broadcast']);
assert.deepEqual(list2, ['broadcast']);
}
// 4. removing all listeners for an event on the destination emitter detaches the forwarding listener from the source emitter
{
const src = new EventEmitter();
const dest = new EventEmitter();
EventEmitter.forward(src, dest, 'cleanup');
const h1 = () => {};
const h2 = () => {};
dest.on('cleanup', h1);
dest.on('cleanup', h2);
assert.equal(src.listenerCount('cleanup'), 1);
dest.off('cleanup', h1);
assert.equal(src.listenerCount('cleanup'), 1);
dest.off('cleanup', h2);
assert.equal(src.listenerCount('cleanup'), 0);
}
// 5. forward supports an array of multiple event names managed independently
{
const src = new EventEmitter();
const dest = new EventEmitter();
EventEmitter.forward(src, dest, ['first', 'second']);
assert.equal(src.listenerCount('first'), 0);
assert.equal(src.listenerCount('second'), 0);
const firstCalls = [];
const secondCalls = [];
dest.on('first', (x) => firstCalls.push(x));
assert.equal(src.listenerCount('first'), 1);
assert.equal(src.listenerCount('second'), 0);
dest.on('second', (y) => secondCalls.push(y));
assert.equal(src.listenerCount('second'), 1);
src.emit('first', 'data-1');
src.emit('second', 'data-2');
assert.deepEqual(firstCalls, ['data-1']);
assert.deepEqual(secondCalls, ['data-2']);
dest.removeAllListeners('first');
assert.equal(src.listenerCount('first'), 0);
assert.equal(src.listenerCount('second'), 1);
}
// 6. forward accepts an optional custom emit function in options to intercept forwarded events
{
const src = new EventEmitter();
const dest = new EventEmitter();
const intercepted = [];
EventEmitter.forward(src, dest, 'custom', {
emit(name, ...args) {
intercepted.push({ name, args });
dest.emit(name, ...args.map((s) => s.toUpperCase()));
}
});
const received = [];
dest.on('custom', (val) => received.push(val));
src.emit('custom', 'lowercase');
assert.deepEqual(intercepted, [{ name: 'custom', args: ['lowercase'] }]);
assert.deepEqual(received, ['LOWERCASE']);
}
Seeder de origen
anónimo