Ejemplo
bare-events 2.9.1: prototype
Muestra verificada para npm bare-events 2.9.1: prototype. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó.
sha256:19099568ae57f8d07e3307c6d632a9bb7956794cfe15927734b750b836d14ed5
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.prototype in pkg:npm/bare-events@2.9.1
- Paquetes
- Símbolos
-
- bare-events.prototype
- Entorno
- node 22.23.2
- Creado
- 2026-08-26T11:37:56Z
Contrato
- EventEmitter.prototype defines core event emitter methods and instance prototype chain
- Subclasses extending EventEmitter inherit prototype methods and manage events
- Prototypal objects inheriting EventEmitter.prototype auto-initialize lazy event state
- Listener registration and removal prototype methods return the instance for method chaining
- listeners returns listener descriptor tuples while rawListeners returns unwrapped handler functions
- newListener and removeListener lifecycle events are emitted during prototype mutation methods
- removeAllListeners clears specified event or all events emitting removeListener hooks
- getMaxListeners and setMaxListeners interact with instance and default settings
- emit triggers registered error listeners synchronously with error payload
Archivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.cjs
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.prototype 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.prototype
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:13eda6278d0bb72f2be20af067462acef7961aa6e1bd8c3e48fe23d73b52b10b","constraints":{"executionContext":"node"},"contract":["EventEmitter.prototype defines core event emitter methods and instance prototype chain","Subclasses extending EventEmitter inherit prototype methods and manage events","Prototypal objects inheriting EventEmitter.prototype auto-initialize lazy event state","Listener registration and removal prototype methods return the instance for method chaining","listeners returns listener descriptor tuples while rawListeners returns unwrapped handler functions","newListener and removeListener lifecycle events are emitted during prototype mutation methods","removeAllListeners clears specified event or all events emitting removeListener hooks","getMaxListeners and setMaxListeners interact with instance and default settings","emit triggers registered error listeners synchronously with error payload"],"goal":"verify bare-events.prototype in pkg:npm/bare-events@2.9.1","kind":"HOW","packages":["pkg:npm/bare-events@2.9.1"],"schemaVersion":1,"symbols":["bare-events.prototype"]},"contractCommand":["node","test/contract.cjs"],"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/bare-events@2.9.1"],"schemaVersion":1,"subject":"pkg:npm/bare-events@2.9.1","symbols":["bare-events.prototype"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-bare-events-prototype",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-bare-events-prototype",
"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-prototype",
"version": "1.0.0",
"private": true,
"dependencies": {
"bare-events": "2.9.1"
}
}
{
"schemaVersion": 1,
"goal": "verify bare-events.prototype in pkg:npm/bare-events@2.9.1",
"kind": "HOW",
"packages": [
"pkg:npm/bare-events@2.9.1"
],
"symbols": [
"bare-events.prototype"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
const assert = require('node:assert/strict');
const EventEmitter = require('bare-events');
// 1. EventEmitter.prototype defines core event emitter methods and instance prototype chain
{
assert.equal(typeof EventEmitter.prototype, 'object');
assert.equal(typeof EventEmitter.prototype.on, 'function');
assert.equal(typeof EventEmitter.prototype.once, 'function');
assert.equal(typeof EventEmitter.prototype.off, 'function');
assert.equal(typeof EventEmitter.prototype.emit, 'function');
assert.equal(typeof EventEmitter.prototype.addListener, 'function');
assert.equal(typeof EventEmitter.prototype.addOnceListener, 'function');
assert.equal(typeof EventEmitter.prototype.prependListener, 'function');
assert.equal(typeof EventEmitter.prototype.prependOnceListener, 'function');
assert.equal(typeof EventEmitter.prototype.removeListener, 'function');
assert.equal(typeof EventEmitter.prototype.removeAllListeners, 'function');
assert.equal(typeof EventEmitter.prototype.listeners, 'function');
assert.equal(typeof EventEmitter.prototype.rawListeners, 'function');
assert.equal(typeof EventEmitter.prototype.listenerCount, 'function');
assert.equal(typeof EventEmitter.prototype.eventNames, 'function');
assert.equal(typeof EventEmitter.prototype.getMaxListeners, 'function');
assert.equal(typeof EventEmitter.prototype.setMaxListeners, 'function');
const ee = new EventEmitter();
assert.ok(ee instanceof EventEmitter);
assert.equal(Object.getPrototypeOf(ee), EventEmitter.prototype);
}
// 2. Subclasses extending EventEmitter inherit prototype methods and manage events
{
class CustomBus extends EventEmitter {
constructor(prefix) {
super();
this.prefix = prefix;
}
publish(topic, msg) {
return this.emit(topic, `${this.prefix}:${msg}`);
}
}
const bus = new CustomBus('app');
assert.ok(bus instanceof EventEmitter);
assert.ok(bus instanceof CustomBus);
let captured = null;
bus.on('message', (val) => {
captured = val;
});
const emitted = bus.publish('message', 'hello');
assert.equal(emitted, true);
assert.equal(captured, 'app:hello');
}
// 3. Prototypal objects inheriting EventEmitter.prototype auto-initialize lazy event state
{
const protoObj = Object.create(EventEmitter.prototype);
assert.ok(protoObj instanceof EventEmitter);
let called = false;
protoObj.on('init', () => {
called = true;
});
protoObj.emit('init');
assert.equal(called, true);
assert.ok(protoObj._events !== undefined);
}
// 4. Listener registration and removal prototype methods return the instance for method chaining
{
const ee = new EventEmitter();
const noop = () => {};
const r1 = ee.on('ev1', noop);
assert.equal(r1, ee);
const r2 = ee.addListener('ev2', noop);
assert.equal(r2, ee);
const r3 = ee.addOnceListener('ev3', noop);
assert.equal(r3, ee);
const r4 = ee.prependListener('ev4', noop);
assert.equal(r4, ee);
const r5 = ee.prependOnceListener('ev5', noop);
assert.equal(r5, ee);
const r6 = ee.off('ev1', noop);
assert.equal(r6, ee);
const r7 = ee.removeListener('ev2', noop);
assert.equal(r7, ee);
const r8 = ee.removeAllListeners('ev4');
assert.equal(r8, ee);
const r9 = ee.removeAllListeners();
assert.equal(r9, ee);
}
// 5. listeners returns listener descriptor tuples while rawListeners returns unwrapped handler functions
{
const ee = new EventEmitter();
const fn1 = () => 'fn1';
const fn2 = () => 'fn2';
ee.on('ping', fn1);
ee.once('ping', fn2);
const list = ee.listeners('ping');
const raw = ee.rawListeners('ping');
assert.equal(list.length, 2);
assert.equal(raw.length, 2);
assert.deepEqual(list[0], [fn1, false]);
assert.deepEqual(list[1], [fn2, true]);
assert.equal(raw[0], fn1);
assert.equal(raw[1], fn2);
list.pop();
assert.equal(ee.listenerCount('ping'), 2);
}
// 6. newListener and removeListener lifecycle events are emitted during prototype mutation methods
{
const ee = new EventEmitter();
const events = [];
ee.on('newListener', (event, listener) => {
events.push({ type: 'new', event, isFn: typeof listener === 'function' });
});
ee.on('removeListener', (event, listener) => {
events.push({ type: 'remove', event, isFn: typeof listener === 'function' });
});
const handler = () => {};
ee.on('status', handler);
ee.off('status', handler);
assert.deepEqual(events, [
{ type: 'new', event: 'removeListener', isFn: true },
{ type: 'new', event: 'status', isFn: true },
{ type: 'remove', event: 'status', isFn: true }
]);
}
// 7. removeAllListeners clears specified event or all events emitting removeListener hooks
{
const ee = new EventEmitter();
const removed = [];
ee.on('removeListener', (name) => {
removed.push(name);
});
const h1 = () => {};
const h2 = () => {};
const h3 = () => {};
ee.on('alpha', h1);
ee.on('alpha', h2);
ee.on('beta', h3);
ee.removeAllListeners('alpha');
assert.equal(ee.listenerCount('alpha'), 0);
assert.equal(ee.listenerCount('beta'), 1);
assert.deepEqual(removed, ['alpha', 'alpha']);
ee.removeAllListeners();
assert.equal(ee.listenerCount('beta'), 0);
assert.deepEqual(ee.eventNames(), []);
}
// 8. getMaxListeners and setMaxListeners interact with instance and default settings
{
const ee = new EventEmitter();
assert.equal(ee.getMaxListeners(), 10);
assert.equal(typeof ee.setMaxListeners, 'function');
ee.setMaxListeners(20);
assert.equal(ee.getMaxListeners(), 10);
}
// 9. emit triggers registered error listeners synchronously with error payload
{
const ee = new EventEmitter();
let caughtError = null;
ee.on('error', (err) => {
caughtError = err;
});
const err = new Error('test-failure');
const handled = ee.emit('error', err);
assert.equal(handled, true);
assert.equal(caughtError, err);
}
Seeder de origen
anónimo