npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

async-glob-events

v1.5.0

Published

Event emitter with glob support on event names and asynchronous listeners

Downloads

33

Readme

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[, ...], callback) will invoke the given callback once all listeners yielded. The callback is called with (err, value).
  • emit({ event : 'name', allResults : true }[, ...], callback) retrieves an array with all non-undefined return values of all listeners.
  • invoke(iterator, scope[, callback]) is an async override of the glob-events implementation. The given callback is invoked once all listeners yielded.
  • this.callback() in listeners returns a callback which has to be invoked for emit to yield. this.callback is a listen instance.

License

MIT