Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

events-bluebird

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

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

  • 1.0.1
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 28 Jun 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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc