# pattern-emitter-promise

> Asynchronous event emitter with RegExp support

Latest version **2.0.1** (published 2017-01-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install pattern-emitter-promise
pnpm add pattern-emitter-promise
yarn add pattern-emitter-promise
bun add pattern-emitter-promise
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2017-01-05 |
| First published | 2015-11-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Tymoteusz Dzienniak |
| Maintainers | mrtambourine |
| Keywords | pattern, event, emitter, regular, expression, regex, promise, async |

## Links

- npm: https://www.npmjs.com/package/pattern-emitter-promise
- Repository: https://github.com/tdzienniak/pattern-emitter-promise
- Homepage: https://github.com/tdzienniak/pattern-emitter-promise#readme
- Issues: https://github.com/tdzienniak/pattern-emitter-promise/issues
- npm.io page: https://npm.io/package/pattern-emitter-promise

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 2.0.1 (latest) — 2017-01-05
- 2.0.0 — 2016-12-19
- 1.0.3 — 2015-11-10
- 1.0.2 — 2015-11-09
- 1.0.1 — 2015-11-08
- 1.0.0 — 2015-11-08

## README

# pattern-emitter-promise
[![Build Status](https://travis-ci.org/tdzienniak/pattern-emitter-promise.svg?branch=master)](https://travis-ci.org/tdzienniak/pattern-emitter-promise)
[![npm version](https://badge.fury.io/js/pattern-emitter-promise.svg)](https://badge.fury.io/js/pattern-emitter-promise)

Asynchronous (using ES2015 Promises) event emitter supporting regex listeners

## Installation

Just do:
```
npm install pattern-emitter-promise
```
and you are ready.

This lib has no external dependencies. Library should be used in environment with Promise global constructor. If there is no such constructor (node 0.10 and earlier or some older browsers), Promise library must be set before first instantiation using `setPromiseLibrary` static method.

## Usage

In your code:
```javascript
import { EventEmitter } from 'event-emitter-promise';

let ee = EventEmitter();

ee.on('fooBar', () => {
    return Promise.resolve('fooBar1');
});

ee.on(/^foo/, (bar) => {
    return Promise.resolve('foo' + bar + '2');
});

ee.on('fooBar', () => {
    return 'fooBar3'; //we support sync return too
});

ee.emit('fooBar', 'Bar').then((results) => {
    results; // ['fooBar1', 'fooBar2', 'fooBar3']
});
```

For more usage examples see [tests](https://github.com/tdzienniak/pattern-emitter-promise/tree/master/test) and read docs in the [code](https://github.com/tdzienniak/pattern-emitter-promise/tree/master/src/index.js).

## License
MIT

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