Ejemplo
bare-events 2.9.1: on
Muestra verificada para npm bare-events 2.9.1: on. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: emitter.on registers an event…
sha256:8d7ab6ede3695b1749852c9ed05fa780132c59a451ebaad82e90023e584de458
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
linux 24 · ubuntu · glibc 2.39 x64 npm
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.on in pkg:npm/bare-events@2.9.1
- Paquetes
- Símbolos
-
- bare-events.on
- Creado
- 2026-08-26T11:29:16Z
Contrato
- emitter.on registers an event listener and returns the emitter instance for chaining
- emitter.on triggers the listener synchronously with all passed arguments when the event is emitted
- emitter.on preserves the EventEmitter instance as this context within listener functions
- emitter.on emits a newListener event before adding the listener to the emitter
- emitter.on appends listeners in registration order and supports multiple listeners for the same event
- EventEmitter.on static helper returns an async iterable yielding argument arrays for emitted events
- EventEmitter.on queues emitted events until consumed by next
- EventEmitter.on respects AbortSignal and rejects with OPERATION_ABORTED when aborted
- EventEmitter.on cleans up its internal listeners when return is called on the iterator
- EventEmitter.on rejects iterator promises when the emitter emits an error event
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.on 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.on
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:7f67a1b0835aad8e24131b9a8762f38910ec4bc8e4c73969ce0afd0695c9ff75","contract":["emitter.on registers an event listener and returns the emitter instance for chaining","emitter.on triggers the listener synchronously with all passed arguments when the event is emitted","emitter.on preserves the EventEmitter instance as this context within listener functions","emitter.on emits a newListener event before adding the listener to the emitter","emitter.on appends listeners in registration order and supports multiple listeners for the same event","EventEmitter.on static helper returns an async iterable yielding argument arrays for emitted events","EventEmitter.on queues emitted events until consumed by next","EventEmitter.on respects AbortSignal and rejects with OPERATION_ABORTED when aborted","EventEmitter.on cleans up its internal listeners when return is called on the iterator","EventEmitter.on rejects iterator promises when the emitter emits an error event"],"goal":"verify bare-events.on in pkg:npm/bare-events@2.9.1","kind":"HOW","packages":["pkg:npm/bare-events@2.9.1"],"schemaVersion":1,"symbols":["bare-events.on"]},"contractCommand":["node","test/contract.mjs"],"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/bare-events@2.9.1"],"schemaVersion":1,"subject":"pkg:npm/bare-events@2.9.1","symbols":["bare-events.on"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-bare-events-on",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-bare-events-on",
"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-on",
"version": "1.0.0",
"type": "module",
"private": true,
"dependencies": {
"bare-events": "2.9.1"
}
}
{
"schemaVersion": 1,
"goal": "verify bare-events.on in pkg:npm/bare-events@2.9.1",
"kind": "HOW",
"packages": [
"pkg:npm/bare-events@2.9.1"
],
"symbols": [
"bare-events.on"
]
}
import assert from 'node:assert/strict';
import EventEmitter from 'bare-events';
// 1. emitter.on registers an event listener and returns the emitter instance for chaining
{
const ee = new EventEmitter();
const res = ee.on('test', () => {});
assert.equal(res, ee);
assert.equal(ee.listenerCount('test'), 1);
}
// 2. emitter.on triggers the listener synchronously with all passed arguments when the event is emitted
{
const ee = new EventEmitter();
const calls = [];
ee.on('greet', (greeting, target, extra) => {
calls.push({ greeting, target, extra });
});
const emitted = ee.emit('greet', 'hello', 'world', 42);
assert.equal(emitted, true);
assert.deepEqual(calls, [{ greeting: 'hello', target: 'world', extra: 42 }]);
}
// 3. emitter.on preserves the EventEmitter instance as this context within listener functions
{
const ee = new EventEmitter();
let capturedThis = null;
ee.on('context', function () {
capturedThis = this;
});
ee.emit('context');
assert.equal(capturedThis, ee);
}
// 4. emitter.on emits a newListener event before adding the listener to the emitter
{
const ee = new EventEmitter();
const events = [];
ee.on('newListener', (eventName, listenerFn) => {
events.push({
eventName,
fn: listenerFn,
countBeforeAdd: ee.listenerCount(eventName)
});
});
const customHandler = () => {};
ee.on('custom', customHandler);
assert.equal(events.length, 1);
assert.equal(events[0].eventName, 'custom');
assert.equal(events[0].fn, customHandler);
assert.equal(events[0].countBeforeAdd, 0);
assert.equal(ee.listenerCount('custom'), 1);
}
// 5. emitter.on appends listeners in registration order and supports multiple listeners for the same event
{
const ee = new EventEmitter();
const order = [];
ee.on('order', () => order.push('first'));
ee.on('order', () => order.push('second'));
ee.on('order', () => order.push('third'));
ee.emit('order');
assert.deepEqual(order, ['first', 'second', 'third']);
}
// 6. EventEmitter.on static helper returns an async iterable yielding argument arrays for emitted events
{
const ee = new EventEmitter();
const iterator = EventEmitter.on(ee, 'stream');
assert.equal(typeof iterator[Symbol.asyncIterator], 'function');
const pendingNext = iterator.next();
ee.emit('stream', 'alpha', 100);
const res = await pendingNext;
assert.deepEqual(res, { value: ['alpha', 100], done: false });
}
// 7. EventEmitter.on queues emitted events until consumed by next
{
const ee = new EventEmitter();
const iterator = EventEmitter.on(ee, 'batch');
ee.emit('batch', 1);
ee.emit('batch', 2);
const res1 = await iterator.next();
const res2 = await iterator.next();
assert.deepEqual(res1.value, [1]);
assert.deepEqual(res2.value, [2]);
}
// 8. EventEmitter.on respects AbortSignal and rejects with OPERATION_ABORTED when aborted
{
const ee = new EventEmitter();
const ac = new AbortController();
const iterator = EventEmitter.on(ee, 'aborted-stream', { signal: ac.signal });
ac.abort('stop');
await assert.rejects(
async () => {
await iterator.next();
},
(err) => {
assert.equal(err.code, 'OPERATION_ABORTED');
return true;
}
);
}
// 9. EventEmitter.on cleans up its internal listeners when return is called on the iterator
{
const ee = new EventEmitter();
const iterator = EventEmitter.on(ee, 'cleanup');
assert.equal(ee.listenerCount('cleanup'), 1);
const closeRes = await iterator.return();
assert.deepEqual(closeRes, { done: true });
assert.equal(ee.listenerCount('cleanup'), 0);
}
// 10. EventEmitter.on rejects iterator promises when the emitter emits an error event
{
const ee = new EventEmitter();
const iterator = EventEmitter.on(ee, 'faulty');
const pendingNext = iterator.next();
const sampleErr = new Error('simulated failure');
ee.emit('error', sampleErr);
await assert.rejects(
async () => {
await pendingNext;
},
(err) => {
assert.equal(err, sampleErr);
return true;
}
);
}
Seeder de origen
anónimo