promised-event

1.0.2 • Public • Published

promised-event

License Build status

Simply get a promise for a specified event

Promises the next dispatch of a specified EventEmitter event. Nothing more, nothing less.

Installation & usage

npm install promised-event
cosnt promiseEvent = require('promised-event');
const emitter = new EventEmitter();
promiseEvent(emitter, 'myevent').then((answer) => {
    console.log(answer);
});
emitter.emit('myevent', 42);
// 42

Want to reject on error?

Simply do

const promise = promiseEvent(stream, 'error').then(Promise.reject);

Then you can write

promise.catch((err) => {
    console.log('oh no!');
});

API

promiseEvent(emitter, eventName)

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i promised-event

Weekly Downloads

1

Version

1.0.2

License

none

Last publish

Collaborators

  • jd342