esm-itter
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

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.

Package Sidebar

Install

npm i esm-itter

Weekly Downloads

31

Version

0.3.0

License

MIT

Unpacked Size

16.3 kB

Total Files

9

Last publish

Collaborators

  • tillsanders