# event-mux

> event-mux

Latest version **0.0.0** (published 2015-06-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install event-mux
pnpm add event-mux
yarn add event-mux
bun add event-mux
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.0 |
| Published | 2015-06-02 |
| First published | 2015-06-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | yoshuawuyts |

## Links

- npm: https://www.npmjs.com/package/event-mux
- Repository: https://github.com/yoshuawuyts/event-mux
- Homepage: https://github.com/yoshuawuyts/event-mux#readme
- Issues: https://github.com/yoshuawuyts/event-mux/issues
- npm.io page: https://npm.io/package/event-mux

## Recent versions

- 0.0.0 (latest) — 2015-06-02

## README

# event-mux
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![Downloads][downloads-image]][downloads-url]
[![js-standard-style][standard-image]][standard-url]

Duplex event multiplexer.

## Installation
```bash
$ npm install event-mux
```

## Usage
```js
const EventEmitter = require('events').EventEmitter
const mux = require('event-mux')

const emitter = mux({
  1: new EventEmitter(),
  2: new EventEmitter()
})

emitter.on('1:beep', () => console.log('beep called'))
emitter.on('2:boop', () => console.log('boop called'))

emitter.emit('1:beep')
// => 'beep called'

emitter.emit('2:boop')
// => 'boop called'
```

## API

### emitter = mux(emitters)
Compose multiple event emitters by namespacing them by their keys. Returns an
instance of [`EventEmitter2`][ee2].

### emitter.emit(event, data)
Emit an event.

### emitter.on(event, cb)
Listen to a namespaced event.

## Why?
Using a lot of `EventEmitter`s in an application can lead to complex,
interdependent code. By wrapping emitters together the pain is mitigated by
being able to pass a single object around rather than pulling in each emitter
manually. This reduces complexity from `n^2` possible connections to `n`
connections.

## License
[MIT](https://tldrlegal.com/license/mit-license)

[npm-image]: https://img.shields.io/npm/v/event-mux.svg?style=flat-square
[npm-url]: https://npmjs.org/package/event-mux
[travis-image]: https://img.shields.io/travis/yoshuawuyts/event-mux.svg?style=flat-square
[travis-url]: https://travis-ci.org/yoshuawuyts/event-mux
[coveralls-image]: https://img.shields.io/coveralls/yoshuawuyts/event-mux.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/yoshuawuyts/event-mux?branch=master
[downloads-image]: http://img.shields.io/npm/dm/event-mux.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/event-mux
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: https://github.com/feross/standard

[ee2]: https://github.com/asyncly/EventEmitter2

---
_Source: https://npm.io/package/event-mux · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
