Skip to content

ESMitter is a fork of the popular EventEmitter3 with a focus on EcmaScript module syntax, TypeScript and modern tooling.

License

Notifications You must be signed in to change notification settings

tillsanders/esm-itter

 
 

Repository files navigation

ESMitter

ESMitter (read: E-S-Emitter; a pun on ESM + emitter) is an event emitter compatible with Node.js and modern browsers. It is a fork of EventEmitter3, but natively TypeScript, ESM-only and with more modern tooling. ESMitter is currently in alpha stage. The complete codebase has been converted to TypeScript and EcmaScript module syntax (ESM). ESMitter is currently less performant than EventEmitter3, but still fast.

Version npmCICoverage Status

The module is API compatible with the EventEmitter that ships by default with Node.js but there are some slight differences:

  • Domain support has been removed.
  • We do not throw an error when you emit an error event and nobody is listening.
  • The newListener and removeListener events have been removed as they are useful only in some uncommon use-cases.
  • The setMaxListeners, getMaxListeners, prependListener and prependOnceListener methods are not available.
  • Support for custom context for events so there is no need to use fn.bind.
  • The removeListener method removes all matching listeners, not only the first.

It's a drop in replacement for existing EventEmitters, but ESM-only.

Installation

$ npm install --save esm-itter

Usage

After installation the only thing you need to do is import the module:

import { ESMitter } from "esm-itter";

Tests and benchmarks

This module is well tested. You can run:

  • npm test to run the tests under Node.js.
  • npm run test-browser to run the tests in real browsers via Sauce Labs.

We also have a set of benchmarks to compare EventEmitter3 with some available alternatives. To run the benchmarks run npm run benchmark.

Tests and benchmarks are not included in the npm package. If you want to play with them you have to clone the GitHub repository. Note that you will have to run an additional npm i in the benchmarks folder before npm run benchmark.

License & Authors

This module is licensed under MIT.

It is a fork of the wonderful EventEmitter3 by Arnout Kazemier and has been converted to TypeScript and ESM by Till Sanders. For ES3 and CommonJS support, as well as superior performance, please use EventEmitter3.

About

ESMitter is a fork of the popular EventEmitter3 with a focus on EcmaScript module syntax, TypeScript and modern tooling.

Topics

Resources

License

Stars

Watchers

Forks

Languages

  • TypeScript 52.9%
  • JavaScript 46.7%
  • Shell 0.4%