Exemplo
bare-events 2.9.1: on
Amostra verificada para npm bare-events 2.9.1: on. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: emitter.on registers an event listener…
sha256:8d7ab6ede3695b1749852c9ed05fa780132c59a451ebaad82e90023e584de458
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
- 2
- 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 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
- Pacotes
- Símbolos
-
- bare-events.on
- Criado
- 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
Arquivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
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 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 origem
anônimo