Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/inikulin/promisify-event
Promisify EventEmitter's event.
https://github.com/inikulin/promisify-event
Last synced: 14 days ago
JSON representation
Promisify EventEmitter's event.
- Host: GitHub
- URL: https://github.com/inikulin/promisify-event
- Owner: inikulin
- License: mit
- Created: 2015-12-10T13:10:38.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-09-03T11:33:16.000Z (about 6 years ago)
- Last Synced: 2024-10-03T21:17:17.311Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 35
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# promisify-event
[![Build Status](https://api.travis-ci.org/inikulin/promisify-event.svg)](https://travis-ci.org/inikulin/promisify-event)*Promisify EventEmitter's event.*
## Install
```
npm install promisify-event
```## Usage
```js
const promisifyEvent = require('promisify-event');// Promisify server's `listening` event:
promisifyEvent(server, `listening`).then(() => {
// ...
});// Promisify `error` event. `error` event always rejects the promise:
promisifyEvent(server, 'error').catch(() => {
// ...
});// Cancel event subscription and promise (it will be never fulfilled):
var listeningPromise = promisifyEvent(server, `listening`);listeningPromise.cancel();
listeningPromise.then(() => {
// Will never happen
});```
## Author
[Ivan Nikulin](https://github.com/inikulin) ([email protected])