npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

promisify-event

1.0.0 • Public • Published

promisify-event

Build Status

Promisify EventEmitter's event.

Install

npm install promisify-event

Usage

const promisifyEvent = require('promisify-event');
 
// Promisify server's `listening` event:
promisify(server, `listening`).then(() => {
  // ...
});
 
// Promisify `error` event. `error` event always rejects the promise:
promisify(server, 'error').catch(() => {
  // ...
});
 
// Cancel event subscription and promise (it will be never fulfilled):
var listeningPromise = promisify(server, `listening`);
 
listeningPromise.cancel();
 
listeningPromise.then(() => {
  // Will never happen
});
 

Author

Ivan Nikulin (ifaaan@gmail.com)

install

npm i promisify-event

Downloadsweekly downloads

104,497

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability