Registry / web-framework / wolfy87-eventemitter

wolfy87-eventemitter

JSON →
library5.2.9jsnpmunverified

wolfy87-eventemitter is a JavaScript event emitter library, primarily designed for use in web browsers but also usable in Node.js environments. It aims to replicate the event-driven paradigm found in Node.js, focusing on a lightweight footprint and fast execution. The library underwent a significant API remapping in its fourth major rewrite to improve clarity and extensibility. While npm shows `5.2.9` as the latest version, the project's GitHub repository has had no activity since 2016, with `v4.2.11` being the last officially tagged release. This indicates the project is no longer actively maintained, making `v4.x` the last stable and documented version.

npm install wolfy87-eventemitter
INSTALL
IMPORT
SIG · WOLFY87-EVENTEMITT
W
wolfy87-eventemitter
web-frameworkjavascriptv5.2.9
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

EventEmitter
✓ import EventEmitter from 'wolfy87-eventemitter';
✗ const EventEmitter = require('wolfy87-eventemitter');
ESM import for modern bundlers or Node.js. Older versions and environments typically use CommonJS `require` or global access.
EventEmitter
✓ const EventEmitter = require('wolfy87-eventemitter');
✗ import EventEmitter from 'wolfy87-eventemitter';
CommonJS `require` for Node.js (prior to ESM) or older bundlers. The package might expose a global `EventEmitter` in browser environments when included via a script tag.
typeof EventEmitter
✓ import type EventEmitter from 'wolfy87-eventemitter';
TypeScript type import. The library ships its own type definitions.

Demonstrates basic event handling: registering, emitting, one-time listeners, and removing listeners.

import EventEmitter from 'wolfy87-eventemitter'; const emitter = new EventEmitter(); // Register a listener for the 'data' event emitter.on('data', (payload: string) => { console.log('Received data:', payload); }); // Register a 'once' listener for the 'init' event emitter.once('init', () => { console.log('Application initialized.'); }); // Emit the 'init' event emitter.emit('init'); // This will not log again as 'once' listeners are removed after first emission emitter.emit('init'); // Emit the 'data' event with a payload emitter.emit('data', 'Hello Event World!'); // Remove a specific listener const anotherListener = (num: number) => console.log('Number received:', num); emitter.on('number', anotherListener); emitter.emit('number', 42); emitter.off('number', anotherListener); emitter.emit('number', 100); // This will not log // Remove all listeners for a specific event emitter.on('cleanup', () => console.log('Cleaning up 1')); emitter.on('cleanup', () => console.log('Cleaning up 2')); emitter.emit('cleanup'); emitter.removeAllListeners('cleanup'); emitter.emit('cleanup'); // No output
Debug
Known issues
breakingThe project is abandoned. While `npm` lists `5.2.9`, the GitHub repository has seen no activity since 2016, and `v4.2.11` is the last official release tag. No documentation or migration guides exist for v5.
fix
Consider migrating to an actively maintained event emitter library such as `eventemitter3` or Node.js's built-in `events` module if in a Node environment.
affects: >=5.0.0
breakingStarting with `v4.2.11`, the project license changed from MIT to The Unlicense. This is a significant shift in licensing terms, moving to public domain dedication.
fix
Review The Unlicense terms to ensure compliance with your project's legal requirements.
affects: >=4.2.11
gotchaThe `EventEmitter` API underwent a significant remapping and redesign in its fourth major rewrite (v4.x). If upgrading from very old versions (pre-4.x), many method names and behaviors will have changed.
fix
Refer to the v4.x API documentation for the correct method names and usage patterns, specifically `on`, `emit`, `off`, `once`, `hasListeners`, `getListeners`, `removeAllListeners`.
affects: <4.0.0
gotchaThe `removeAllListeners` method was added as an alias to `removeEvent` in `v4.2.4` to align with the Node.js API. While `removeEvent` still functions, `removeAllListeners` is the more consistent and recommended method name.
fix
Update calls to `removeEvent(eventName)` to `removeAllListeners(eventName)` for improved clarity and Node.js API conformity.
affects: <4.2.4
gotchaAn infinite recursion bug was present in `addOnceListener` in versions prior to `v4.2.3` under specific conditions.
fix
Ensure you are using `v4.2.3` or higher to mitigate potential infinite recursion issues with `once` listeners.
affects: <4.2.3
Errors
Common errors & fixes
TypeError: EventEmitter is not a constructor
Attempting to instantiate `EventEmitter` without correctly importing or accessing it, often due to CommonJS/ESM module mismatches or incorrect global access in the browser.
fix
Ensure you are using the correct import/require syntax for your environment. For modern ESM environments: `import EventEmitter from 'wolfy87-eventemitter';`. For CommonJS: `const EventEmitter = require('wolfy87-eventemitter');`. In browsers (script tag), it might be globally available as `window.EventEmitter`.
TypeError: Cannot read properties of undefined (reading 'on')
Attempting to call methods like `on` or `emit` on an `EventEmitter` instance that is undefined or null, usually due to incorrect initialization or scope issues.
fix
Verify that your `EventEmitter` instance (`emitter` in examples) is properly initialized with `new EventEmitter()` before attempting to use its methods.
Uncaught TypeError: Android 2.2 RegExp type check issue
A bug in older Android 2.2 browsers related to `RegExp` type checking prevented proper functionality.
fix
Upgrade to `v4.2.7` or later, which includes a fix for this specific Android 2.2 browser bug. Note that this is for a very old browser version.
Upgrade
Version history
5.2.9latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources
wolfy87-eventemitter — npm install wolfy87-eventemitter · libregistry