샘플
bare-events 2.9.1: on
검증된 샘플 — npm bare-events 2.9.1: on. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: emitter.on registers an event listener and returns the…
sha256:8d7ab6ede3695b1749852c9ed05fa780132c59a451ebaad82e90023e584de458
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 2
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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 |
케이스
HOW- 목표
- verify bare-events.on in pkg:npm/bare-events@2.9.1
- 심벌
-
- bare-events.on
- 생성일
- 2026-08-26T11:29:16Z
컨트랙트
- 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
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
소스
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;
}
);
}
오리진 시더
익명