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

happening

v0.0.2

Published

Distributed network-based event emitter

Downloads

4

Readme

happening

Distributed network-based event emitter for NodeJS.

NOTE: This is totally work in progress, and you should NOT rely on this for anything right now.

Installation

$ npm install happening

Note that happening depends on One, a distributed message queue based on ØMQ. So, if you're having a hard time installing, refer to its installation instructions.

Usage

You can use happening just like you would with any other event emitter. Here's a quick example:

var Happening = require('happening');

var happening = Happening.create(function (err) {
    if (err) {
        throw err;
    }

    happening.on('my_event', function (param1, param2) {
        console.log('got called with', param1, 'and', param2);
    });

    setInterval(function () {
        happening.emit('my_event', 'this', 'that');
    }, 500);
});

Considerations

Here's a list of things you should keep in mind when using happening.

Namespacing

Any emitter you create will join other emitters on the same network automatically, and act as one logical emitter. If you need multiple logical emitters, you can specify a namespace option:

var Happening = require('happening');

var happening = Happening.create({
        namespace: 'my_own_namespace'
    }, function (err) {
    if (err) {
        throw err;
    }

    happening.on('my_event', function (param1, param2) {
        console.log('got called with', param1, 'and', param2);
    });

    setInterval(function () {
        happening.emit('my_event', 'this', 'that');
    }, 500);
});

This emitter will only join other emitters that belong to the same namespace.

Using once()

If you add once() listeners on two separate nodes of the emitter, both will run once. Remember that in practice, you ran once() twice.

Cluster awareness

happening takes a few milliseconds to get up an running, which is why you have asynchronous create(), which will only call back once emitter has connected to at least one other node. If you want to raise the number of nodes it should wait for, you can pass a readyThreshold option, like so:

var Happening = require('happening');

var happening = Happening.create({
        readyThreshold: 3
    }, function (err) {
    if (err) {
        throw err;
    }

    console.log('found at least 3 nodes!');
});

License

Released under the MIT License.