Socket
Socket
Sign inDemoInstall

events-bluebird

Package Overview
Dependencies
1
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    events-bluebird

events.EventEmitter wrapper implements `emitAsync` method which awaits promises returned from event listeners


Version published
Maintainers
1
Install size
40.2 kB
Created

Readme

Source

events-bluebird

Build Status Test Coverage

This is a lightweight wrapper for native node events.
Adds EventEmitter.prototype.emitAsyncSeries & EventEmitter.prototype.emitAsyncParallel methods. The API reflects native EventEmitter API with the following necessary changes:

  • Added methods return a Promise object which when fulfilled, returns true if the event had listeners, false otherwise
  • node's deprecated domain feature is not supported

Installation

npm install events-bluebird

Example


var EventEmitter = require('events-bluebird').EventEmitter;

var emitter = new EventEmitter;

emitter.on('event', function(param) {
    return new Promise(function(resolve, reject) {
        setTimeout(function() {
            console.log('first');
            return resolve();
        }, 500);
    });
});

emitter.on('event', function(param) {
    console.log('later');
});

emitter.emitAsyncSeries('event', 'param').then(function(hadListeners) {
    console.log(hadListeners);//true
});

// Output:
// first
// later
// true

Tests

npm test

Keywords

FAQs

Last updated on 13 Nov 2017

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc