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

asyncemit

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asyncemit

Asynchronously emit event an event based on the arguments length.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
increased by39.03%
Maintainers
1
Weekly downloads
 
Created
Source

asyncemit

Version npmBuild StatusDependenciesCoverage StatusIRC channel

The asyncemit allows you to emit an event to an EventEmitter3 asynchronously.

Installation

The module is released in the public npm registry and can be installed using:

npm install --save asyncemit

Usage

To make this pattern work we have make a couple assumptions about the way this module is used:

  1. This method should be added on either a class that inherits from the EventEmitter or on a new EventEmitter instance.
  2. The amount of arguments you pass is the same amount of arguments required for your event to be seen as async emitter.

See the following example:

var asyncemit = require('asyncemit')
  , EventEmitter = require('eventemitter3');

var ee = new EventEmitter();
ee.asyncemit = asyncemit;

//
// The next `foo` listeners will not be executed until this `next` is called. 
//
ee.on('foo', function (arg, next) {
  // do things with arg?
  next();
});

//
// Still executed, by sync
//
ee.on('foo', function (arg) {

});

ee.asyncemit('foo', 'bar', function (err) {
  //
  // The error argument will be set if one of the async listeners called the
  // `next` callback with an `error` arugment.
  //
});

License

MIT

Keywords

FAQs

Package last updated on 30 Mar 2015

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