CodeSampleX

Sample

events-universal 1.0.1

Verified sample for npm events-universal 1.0.1. The contract ran on node 22 · linux alpine/x64 · docker and passed: events-universal exports an EventEmitter…

sha256:16cb40fcc5038e37aef2ba238cbe54581bb41f65ae2f9c9ac2ed70b081e61d18

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 npm 10

Verification-run environments

Environment Contract Stages Run
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-23

Case

HOW
Goal
verify pkg:npm/events-universal@1.0.1
Packages
Environment
node 22.23.2
Created
2026-08-23T15:39:51Z

Contract

  1. events-universal exports an EventEmitter constructor
  2. EventEmitter instances register and trigger event listeners with arguments via on and emit
  3. EventEmitter.once registers one-time event listeners that automatically unregister after invocation
  4. EventEmitter.removeListener and off remove specific registered listeners
  5. EventEmitter.removeAllListeners removes all listeners for a given event or all events
  6. EventEmitter.listenerCount returns the number of registered listeners for an event
  7. EventEmitter.eventNames returns an array of registered event names
  8. EventEmitter.prependListener adds listeners to the beginning of the listener array

Files

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

Download the source artifact (tar.gz)

Source

PROMPT.md
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 pkg:npm/events-universal@1.0.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/events-universal@1.0.1

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.
csx.json
{"case":{"caseId":"case:sha256:cfca1c43f1831b21bd148195984dd2415cc9e32ff86ed31eaaea7a767b7dd009","contract":["events-universal exports an EventEmitter constructor","EventEmitter instances register and trigger event listeners with arguments via on and emit","EventEmitter.once registers one-time event listeners that automatically unregister after invocation","EventEmitter.removeListener and off remove specific registered listeners","EventEmitter.removeAllListeners removes all listeners for a given event or all events","EventEmitter.listenerCount returns the number of registered listeners for an event","EventEmitter.eventNames returns an array of registered event names","EventEmitter.prependListener adds listeners to the beginning of the listener array"],"goal":"verify pkg:npm/events-universal@1.0.1","kind":"HOW","packages":["pkg:npm/events-universal@1.0.1"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/events-universal@1.0.1"],"schemaVersion":1,"subject":"pkg:npm/events-universal@1.0.1","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-events-universal",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-events-universal",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "events-universal": "1.0.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
        }
      }
    },
    "node_modules/events-universal": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/events-universal/-/events-universal-1.0.1.tgz",
      "integrity": "sha512-LUd5euvbMLpwOF8m6ivPCbhQeSiYVNb8Vs0fQ8QjXo0JTkEHpz8pxdQf0gStltaPpw0Cca8b39KxvK9cfKRiAw==",
      "license": "Apache-2.0",
      "dependencies": {
        "bare-events": "^2.7.0"
      }
    }
  }
}
package.json
{
  "name": "sample-events-universal",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room code sample for events-universal@1.0.1",
  "license": "MIT-0",
  "dependencies": {
    "events-universal": "1.0.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/events-universal@1.0.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/events-universal@1.0.1"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import EventEmitter from 'events-universal';

// 1. events-universal exports an EventEmitter constructor
assert.equal(typeof EventEmitter, 'function', 'EventEmitter export should be a constructor function');
assert.equal(EventEmitter.EventEmitter, EventEmitter, 'EventEmitter.EventEmitter should reference itself');

// 2. EventEmitter instances register and trigger event listeners with arguments via on and emit
const emitter = new EventEmitter();
const receivedArgs = [];
emitter.on('data', (a, b) => {
  receivedArgs.push([a, b]);
});
const emitResult = emitter.emit('data', 'hello', 42);
assert.equal(emitResult, true, 'emit should return true when listeners exist');
assert.deepEqual(receivedArgs, [['hello', 42]], 'listener should receive passed arguments');

// 3. EventEmitter.once registers one-time event listeners that automatically unregister after invocation
let onceCount = 0;
emitter.once('single', (val) => {
  onceCount += val;
});
emitter.emit('single', 10);
emitter.emit('single', 20);
assert.equal(onceCount, 10, 'once listener should execute exactly once');

// 4. EventEmitter.removeListener and off remove specific registered listeners
let removedCalls = 0;
const listenerToRemove = () => {
  removedCalls++;
};
emitter.on('remove-test', listenerToRemove);
emitter.emit('remove-test');
assert.equal(removedCalls, 1, 'listener should be called before removal');
emitter.removeListener('remove-test', listenerToRemove);
emitter.emit('remove-test');
assert.equal(removedCalls, 1, 'listener should not be called after removeListener');

emitter.on('off-test', listenerToRemove);
emitter.off('off-test', listenerToRemove);
emitter.emit('off-test');
assert.equal(removedCalls, 1, 'off should alias removeListener');

// 5. EventEmitter.removeAllListeners removes all listeners for a given event or all events
let countA = 0;
let countB = 0;
emitter.on('evt-a', () => countA++);
emitter.on('evt-a', () => countA++);
emitter.on('evt-b', () => countB++);
emitter.removeAllListeners('evt-a');
emitter.emit('evt-a');
emitter.emit('evt-b');
assert.equal(countA, 0, 'removeAllListeners should remove all listeners for evt-a');
assert.equal(countB, 1, 'evt-b listener should remain intact');
emitter.removeAllListeners();
emitter.emit('evt-b');
assert.equal(countB, 1, 'removeAllListeners without args should remove all listeners across all events');

// 6. EventEmitter.listenerCount returns the number of registered listeners for an event
const countEmitter = new EventEmitter();
assert.equal(countEmitter.listenerCount('ping'), 0, 'initial listenerCount should be 0');
const noop1 = () => {};
const noop2 = () => {};
countEmitter.on('ping', noop1);
assert.equal(countEmitter.listenerCount('ping'), 1, 'listenerCount should be 1 after one registration');
countEmitter.on('ping', noop2);
assert.equal(countEmitter.listenerCount('ping'), 2, 'listenerCount should be 2 after second registration');

// 7. EventEmitter.eventNames returns an array of registered event names
const namesEmitter = new EventEmitter();
assert.deepEqual(namesEmitter.eventNames(), [], 'eventNames should be empty initially');
namesEmitter.on('first', noop1);
namesEmitter.on('second', noop2);
assert.deepEqual(namesEmitter.eventNames().sort(), ['first', 'second'].sort(), 'eventNames should return registered events');

// 8. EventEmitter.prependListener adds listeners to the beginning of the listener array
const orderEmitter = new EventEmitter();
const executionOrder = [];
orderEmitter.on('order', () => executionOrder.push('second'));
orderEmitter.prependListener('order', () => executionOrder.push('first'));
orderEmitter.emit('order');
assert.deepEqual(executionOrder, ['first', 'second'], 'prependListener should execute before previously registered listeners');

console.log('All events-universal contract assertions passed.');

Origin Seeder

anonymous