New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

promised-event

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promised-event

Simply get a promise for a specified event

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

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

Keywords

event

FAQs

Package last updated on 26 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts