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

async-glob-events

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-glob-events

Event emitter with glob support on event names and asynchronous listeners

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-83.33%
Maintainers
1
Weekly downloads
 
Created
Source

async-glob-events.js

Build Status SemVer License

Event emitter with glob support on event names and asynchronous listeners, for node and the browser

Features

  • Inherits all features from glob-events
  • Pass a callback as the last argument to emit and receive asynchronous errors and return values from listeners
  • 100% test coverage

Install with npm

npm install async-glob-events

Browser support

Use Browserify to create a standalone file.

Usage

var AsyncEmitter = require('async-glob-events').AsyncEmitter;
var asyncEmitter = new AsyncEmitter();

asyncEmitter.on('add', function (a, b, callback) {
  setTimeout(function () {
    callback(null, a + b);
  }, 100);
});

asyncEmitter.emit('add', 3, 4, function (err, value) {
  assert.equal(value, 7);
});

Listeners may also return value immediately:

asyncEmitter.on('add', function (a, b) {
  return a + b;
});

This makes it possible to change an implementation from synchronous to asynchronous without modifying the caller.

The callback passed to emit is only invoked once all invoked listeners returned.

AsyncEmitter API

The API is identical to glob-events with these additions:

  • emit({ event : 'name', allResults : true }, ...) may be used to receive an array with all non-undefined return values of all listeners
  • this.callback() may be used in listeners to obtain a callback

License

MIT

Keywords

FAQs

Package last updated on 17 Oct 2014

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