npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

enhanced-event-emitter

v1.3.1

Published

An Even Emitter implementation with enhanced semantics and functionality

Readme

Enhanced Event Emitter

Enhanced Event Emitter (EEE) is a reimagination and reimplementation of the Node.js Event Emitter.

Why?

The standard Event Emitter, as well as its reimplementations (EE2 and EE3), are a mechanism for object to announce events to an unknown number of listeners, and for those listeners to communicate that they want to receive those events. This mechanism is a one-way communication method, allowing emitters to send information but not allowing listeners to reply back or communicate between them in any way.

What EEE tries to solve is that very last problem: communication from listener to emitter and between listeners. We do this by allowing listeners to return values back to the emitter, pass values through to other listeners or even completely stop propagation of the events.

Usage

The main exported symbol is an EventEmitter-like class. You can derive from that class to add the typical .emit and .on methods, among others.

import EEE from 'enhanced-event-emitter';

class SomeClass extends EEE {
  constructor (/* ... */) {
    super();
  }

  /* ... */
}

This class is, however, a proxy: Upon construction, it creates an [EEE.Emitter][class-emitter] object, stored in the __eee object attribute, and redirects all of EEE's methods to methods of this object. It is recommended to use this class as you would a regular EventEmitter for most situations, but see the documentation of [EEE.Emitter][class-emitter] if you need something more custom.

Listening

Adding a listener to an emitter can be done by calling [#on][method-on] or [#once][method-once] in the emitter. These methods accept four arguments:

  • name: The name of the event to listen on
  • hook: The function that will be called when the event fires
  • thisArg: Which object will be bound too the this variable inside the hook function (defaults to the event source)
  • priority: The priority of this listener (defaults to 0 or EEE.PRIORITY.NORMAL)

If you've ever used EventEmitter3, you should recognize the first three arguments. If you haven't, you should recognize the first two and understand the third. The priority, however, might be kind of new to you. What priority means is, essentially, in which order the listeners will be run.

Because we are interested in communication, all events are fired serially: An event listener is not fired until the previous one ends. Being a completely asynchronous environment, of course, we can't really know when an event end, so we rely on the event hook function returning a Promise which fulfillment means the event has ended.

The order in which listeners are fired, then, is determined first by their priority, and then by their order. Priority is just a number, with lower number coming first. There are a few constants for priority inside the EEE.PRIORITY object with the following values:

  • HIGHEST: -1000
  • HIGHER: -100
  • HIGH: -10
  • NORMAL: 0
  • LOW: +10
  • LOWER: +100
  • LOWEST: +1000

Of course, any number would work, but these are there for your convenience.

The hook function will receive a first argument before the objects given to the emit mehtod, which represents the event itself. This [Event][class-event] object can be used to obtain information about the event itself, to stop the event propagation, and to share information with other listeners.

Note: If your hook function can return a result and do all its work that's dependent on the emitter without waiting for something else to end, you can (and should) fulfill the promise early. In particular, if you can return immediately, you should. By returning as early as you can, you allow other listeners to run as soon as possible.

Emitting