Exemple
bare-events 2.9.1: once
Échantillon vérifié pour npm bare-events 2.9.1: once. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.
sha256:6588cc35a188d36b6375a1b9e48f329221d9d9b263eafeda464b3bf6278e743a
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 2
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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 |
Cas
HOW- Objectif
- verify bare-events.once in pkg:npm/bare-events@2.9.1
- Paquets
- Symboles
-
- bare-events.once
- Créé
- 2026-08-26T11:31:14Z
Contrat
- emitter.once registers a listener that is invoked on the first emit and automatically removed for subsequent emissions
- emitter.once returns the EventEmitter instance to allow method chaining
- emitter.addOnceListener functions identically to once as an alias
- emitter.prependOnceListener adds a one-time listener to the beginning of the listener list
- emitter.off and removeListener can remove a once listener before it is emitted
- EventEmitter.once static helper returns a Promise that resolves with an array of emitted event arguments
- EventEmitter.once static helper rejects if the emitter emits an error event while waiting for another event
- EventEmitter.once static helper can listen directly to the error event and resolves with the emitted error
- EventEmitter.once static helper rejects when an AbortSignal option is aborted
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Code source
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.once 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.once
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:dca6e335ec4370dee58cacbfc2162316bc27ce26fc1d7ffeb10bfca5e45ba286","contract":["emitter.once registers a listener that is invoked on the first emit and automatically removed for subsequent emissions","emitter.once returns the EventEmitter instance to allow method chaining","emitter.addOnceListener functions identically to once as an alias","emitter.prependOnceListener adds a one-time listener to the beginning of the listener list","emitter.off and removeListener can remove a once listener before it is emitted","EventEmitter.once static helper returns a Promise that resolves with an array of emitted event arguments","EventEmitter.once static helper rejects if the emitter emits an error event while waiting for another event","EventEmitter.once static helper can listen directly to the error event and resolves with the emitted error","EventEmitter.once static helper rejects when an AbortSignal option is aborted"],"goal":"verify bare-events.once in pkg:npm/bare-events@2.9.1","kind":"HOW","packages":["pkg:npm/bare-events@2.9.1"],"schemaVersion":1,"symbols":["bare-events.once"]},"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.once"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-bare-events-once",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-bare-events-once",
"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-once",
"version": "1.0.0",
"type": "module",
"private": true,
"dependencies": {
"bare-events": "2.9.1"
}
}
{
"schemaVersion": 1,
"goal": "verify bare-events.once in pkg:npm/bare-events@2.9.1",
"kind": "HOW",
"packages": [
"pkg:npm/bare-events@2.9.1"
],
"symbols": [
"bare-events.once"
]
}
import assert from 'node:assert/strict';
import EventEmitter from 'bare-events';
// 1. emitter.once registers a listener that is invoked on the first emit and automatically removed for subsequent emissions
{
const ee = new EventEmitter();
let callCount = 0;
let receivedArgs = null;
ee.once('greet', (a, b) => {
callCount++;
receivedArgs = [a, b];
});
assert.equal(ee.listenerCount('greet'), 1);
const emitted1 = ee.emit('greet', 'hello', 'world');
assert.equal(emitted1, true);
assert.equal(callCount, 1);
assert.deepEqual(receivedArgs, ['hello', 'world']);
assert.equal(ee.listenerCount('greet'), 0);
const emitted2 = ee.emit('greet', 'again', 'there');
assert.equal(emitted2, false);
assert.equal(callCount, 1);
}
// 2. emitter.once returns the EventEmitter instance to allow method chaining
{
const ee = new EventEmitter();
const returned = ee.once('event1', () => {}).once('event2', () => {});
assert.equal(returned, ee);
assert.equal(ee.listenerCount('event1'), 1);
assert.equal(ee.listenerCount('event2'), 1);
}
// 3. emitter.addOnceListener functions identically to once as an alias
{
const ee = new EventEmitter();
let called = false;
ee.addOnceListener('aliasTest', () => {
called = true;
});
assert.equal(ee.listenerCount('aliasTest'), 1);
ee.emit('aliasTest');
assert.equal(called, true);
assert.equal(ee.listenerCount('aliasTest'), 0);
}
// 4. emitter.prependOnceListener adds a one-time listener to the beginning of the listener list
{
const ee = new EventEmitter();
const executionOrder = [];
ee.on('ordered', () => executionOrder.push('normal-1'));
ee.prependOnceListener('ordered', () => executionOrder.push('prepend-once'));
ee.on('ordered', () => executionOrder.push('normal-2'));
ee.emit('ordered');
assert.deepEqual(executionOrder, ['prepend-once', 'normal-1', 'normal-2']);
ee.emit('ordered');
assert.deepEqual(executionOrder, ['prepend-once', 'normal-1', 'normal-2', 'normal-1', 'normal-2']);
}
// 5. emitter.off and removeListener can remove a once listener before it is emitted
{
const ee = new EventEmitter();
let called = false;
const listener = () => {
called = true;
};
ee.once('cancelMe', listener);
assert.equal(ee.listenerCount('cancelMe'), 1);
ee.off('cancelMe', listener);
assert.equal(ee.listenerCount('cancelMe'), 0);
ee.emit('cancelMe');
assert.equal(called, false);
}
// 6. EventEmitter.once static helper returns a Promise that resolves with an array of emitted event arguments
{
const ee = new EventEmitter();
const promise = EventEmitter.once(ee, 'asyncEvent');
ee.emit('asyncEvent', 42, { key: 'value' });
const result = await promise;
assert.deepEqual(result, [42, { key: 'value' }]);
}
// 7. EventEmitter.once static helper rejects if the emitter emits an error event while waiting for another event
{
const ee = new EventEmitter();
const promise = EventEmitter.once(ee, 'expectedEvent');
const testError = new Error('boom');
ee.emit('error', testError);
await assert.rejects(promise, (err) => {
assert.equal(err, testError);
return true;
});
}
// 8. EventEmitter.once static helper can listen directly to the error event and resolves with the emitted error
{
const ee = new EventEmitter();
const promise = EventEmitter.once(ee, 'error');
const testError = new Error('handled error');
ee.emit('error', testError);
const result = await promise;
assert.deepEqual(result, [testError]);
}
// 9. EventEmitter.once static helper rejects when an AbortSignal option is aborted
{
const ee = new EventEmitter();
const ac = new AbortController();
const promise = EventEmitter.once(ee, 'neverEmitted', { signal: ac.signal });
ac.abort(new Error('aborted-reason'));
await assert.rejects(promise, (err) => {
assert.equal(err.code, 'OPERATION_ABORTED');
return true;
});
}
Seeder d'origine
anonyme