CodeSampleX

Sample

chromium-bidi 2.1.2: EventEmitter

Verified sample for npm chromium-bidi 2.1.2: EventEmitter. The contract ran on node 22 · linux alpine/x64 · docker and passed.

sha256:1a40b369fcc0afd970bb45a0c1c0a406a0266b6beeabfb758c87e759a88b1f7a

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 linux 24 · ubuntu · glibc 2.39 x64 npm

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-27

Case

HOW
Goal
verify chromium-bidi.EventEmitter in pkg:npm/chromium-bidi@2.1.2
Packages
Symbols
  • chromium-bidi.EventEmitter
Created
2026-08-27T10:52:22Z

Contract

  1. EventEmitter is instantiated with new EventEmitter()
  2. on binds an event listener and receives emitted data payload
  3. multiple event listeners execute in order of registration
  4. once binds a one-time event listener that executes only on the first emit
  5. off removes an event listener so it is not invoked on subsequent emits
  6. removeAllListeners(event) removes listeners for a specific event while preserving other events
  7. removeAllListeners() without arguments clears all listeners for all events
  8. on, once, off, and removeAllListeners return the EventEmitter instance for method chaining

Files

  • PROMPT.md
  • csx.json
  • index.mjs
  • 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 chromium-bidi.EventEmitter in pkg:npm/chromium-bidi@2.1.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/chromium-bidi@2.1.2
Demonstrate these symbols/APIs:
  - chromium-bidi.EventEmitter

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:2cc04ccb4f4eaa564f01d8b91e9da130f19cc17d5cefb98aed8fca458cc47dc5","contract":["EventEmitter is instantiated with new EventEmitter()","on binds an event listener and receives emitted data payload","multiple event listeners execute in order of registration","once binds a one-time event listener that executes only on the first emit","off removes an event listener so it is not invoked on subsequent emits","removeAllListeners(event) removes listeners for a specific event while preserving other events","removeAllListeners() without arguments clears all listeners for all events","on, once, off, and removeAllListeners return the EventEmitter instance for method chaining"],"goal":"verify chromium-bidi.EventEmitter in pkg:npm/chromium-bidi@2.1.2","kind":"HOW","packages":["pkg:npm/chromium-bidi@2.1.2"],"schemaVersion":1,"symbols":["chromium-bidi.EventEmitter"]},"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/chromium-bidi@2.1.2"],"schemaVersion":1,"subject":"pkg:npm/chromium-bidi@2.1.2","symbols":["chromium-bidi.EventEmitter"],"verifierAdapter":"node-typescript@1"}
index.mjs
import { EventEmitter } from 'chromium-bidi/lib/esm/utils/EventEmitter.js';

export function createEventEmitter() {
  return new EventEmitter();
}

export { EventEmitter };
package-lock.json
{
  "name": "sample-chromium-bidi-eventemitter",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-chromium-bidi-eventemitter",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "chromium-bidi": "2.1.2"
      }
    },
    "node_modules/chromium-bidi": {
      "version": "2.1.2",
      "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-2.1.2.tgz",
      "integrity": "sha512-vtRWBK2uImo5/W2oG6/cDkkHSm+2t6VHgnj+Rcwhb0pP74OoUb4GipyRX/T/y39gYQPhioP0DPShn+A7P6CHNw==",
      "license": "Apache-2.0",
      "dependencies": {
        "mitt": "^3.0.1",
        "zod": "^3.24.1"
      },
      "peerDependencies": {
        "devtools-protocol": "*"
      }
    },
    "node_modules/devtools-protocol": {
      "version": "0.0.1686980",
      "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1686980.tgz",
      "integrity": "sha512-NnnxGO1/cRffXL29DqGysbfgCcsYoIxprtmXgh+UDXFvhTwhRBewcRdGlEXvc3cmROi04JRmd2PqCURsijW25A==",
      "license": "BSD-3-Clause",
      "peer": true
    },
    "node_modules/mitt": {
      "version": "3.0.1",
      "resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz",
      "integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==",
      "license": "MIT"
    },
    "node_modules/zod": {
      "version": "3.25.76",
      "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",
      "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==",
      "license": "MIT",
      "funding": {
        "url": "https://github.com/sponsors/colinhacks"
      }
    }
  }
}
package.json
{
  "name": "sample-chromium-bidi-eventemitter",
  "version": "1.0.0",
  "private": true,
  "description": "verify chromium-bidi.EventEmitter in pkg:npm/chromium-bidi@2.1.2",
  "type": "module",
  "main": "index.mjs",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "chromium-bidi": "2.1.2"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify chromium-bidi.EventEmitter in pkg:npm/chromium-bidi@2.1.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/chromium-bidi@2.1.2"
  ],
  "symbols": [
    "chromium-bidi.EventEmitter"
  ]
}
test/contract.mjs
import assert from 'node:assert';
import { EventEmitter as DirectEventEmitter } from 'chromium-bidi/lib/esm/utils/EventEmitter.js';
import { EventEmitter as BidiMapperEventEmitter } from 'chromium-bidi/lib/esm/bidiMapper/BidiMapper.js';
import { createEventEmitter, EventEmitter } from '../index.mjs';

async function run() {
  // 1. Verify class exports and construction
  assert.strictEqual(typeof EventEmitter, 'function', 'EventEmitter should be exported as a class/function');
  assert.strictEqual(typeof DirectEventEmitter, 'function', 'DirectEventEmitter should be exported as a class/function');
  assert.strictEqual(typeof BidiMapperEventEmitter, 'function', 'BidiMapperEventEmitter should be exported as a class/function');
  assert.strictEqual(EventEmitter, DirectEventEmitter, 'Index EventEmitter should match DirectEventEmitter');
  assert.strictEqual(BidiMapperEventEmitter, DirectEventEmitter, 'BidiMapper EventEmitter should match DirectEventEmitter');

  const emitter = new EventEmitter();
  assert.ok(emitter instanceof EventEmitter, 'emitter should be an instance of EventEmitter');

  const helperEmitter = createEventEmitter();
  assert.ok(helperEmitter instanceof EventEmitter, 'createEventEmitter should return an EventEmitter instance');

  // 2. Test `on` and `emit`
  const receivedMessages = [];
  const onResult = emitter.on('message', (payload) => {
    receivedMessages.push(payload);
  });
  assert.strictEqual(onResult, emitter, 'on() must return the emitter instance for chaining');

  emitter.emit('message', { id: 1, text: 'first' });
  emitter.emit('message', { id: 2, text: 'second' });

  assert.strictEqual(receivedMessages.length, 2, 'Listener should have received two events');
  assert.deepStrictEqual(receivedMessages[0], { id: 1, text: 'first' });
  assert.deepStrictEqual(receivedMessages[1], { id: 2, text: 'second' });

  // 3. Test multiple listeners on same event
  const order = [];
  emitter.on('multi', () => order.push('listener1'));
  emitter.on('multi', () => order.push('listener2'));
  emitter.emit('multi', null);
  assert.deepStrictEqual(order, ['listener1', 'listener2'], 'Listeners must execute in registration order');

  // 4. Test `once`
  const onceMessages = [];
  const onceResult = emitter.once('single', (payload) => {
    onceMessages.push(payload);
  });
  assert.strictEqual(onceResult, emitter, 'once() must return the emitter instance for chaining');

  emitter.emit('single', 'event-1');
  emitter.emit('single', 'event-2');
  emitter.emit('single', 'event-3');

  assert.strictEqual(onceMessages.length, 1, 'once listener must be invoked only once');
  assert.strictEqual(onceMessages[0], 'event-1', 'once listener must receive the first event payload');

  // 5. Test `off`
  const offMessages = [];
  const handlerToRemove = (payload) => {
    offMessages.push(payload);
  };

  emitter.on('removable', handlerToRemove);
  emitter.emit('removable', 'before-off');
  assert.strictEqual(offMessages.length, 1, 'Listener should receive event before off()');

  const offResult = emitter.off('removable', handlerToRemove);
  assert.strictEqual(offResult, emitter, 'off() must return the emitter instance');

  emitter.emit('removable', 'after-off');
  assert.strictEqual(offMessages.length, 1, 'Listener must not receive event after off()');

  // 6. Test `removeAllListeners(event)` for a specific event
  const eventA = [];
  const eventB = [];
  emitter.on('topicA', (val) => eventA.push(val));
  emitter.on('topicB', (val) => eventB.push(val));

  const removeSpecificResult = emitter.removeAllListeners('topicA');
  assert.strictEqual(removeSpecificResult, emitter, 'removeAllListeners(event) must return the emitter instance');

  emitter.emit('topicA', 'should-be-dropped');
  emitter.emit('topicB', 'should-be-received');

  assert.strictEqual(eventA.length, 0, 'topicA listeners should have been removed');
  assert.strictEqual(eventB.length, 1, 'topicB listeners should remain intact');
  assert.strictEqual(eventB[0], 'should-be-received');

  // 7. Test `removeAllListeners()` without arguments
  const eventC = [];
  emitter.on('topicC', (val) => eventC.push(val));

  const removeAllResult = emitter.removeAllListeners();
  assert.strictEqual(removeAllResult, emitter, 'removeAllListeners() must return the emitter instance');

  emitter.emit('topicB', 'dropped-b');
  emitter.emit('topicC', 'dropped-c');

  assert.strictEqual(eventB.length, 1, 'topicB should receive no new events');
  assert.strictEqual(eventC.length, 0, 'topicC should receive no events');

  console.log('Contract tests passed successfully.');
}

run().catch((err) => {
  console.error('Contract test failed:', err);
  process.exit(1);
});

Origin Seeder

anonymous