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

event-box

v2.2.0

Published

Event dispatcher

Downloads

66

Readme

event-box

event-box is an alternative to node's built in EventEmitter. It exposes a similar API but is not intended to be a drop-in replacement; some differences exist.

Hierarchical Events

event-box supports hierarchical events, using : as a separator. If event foo:bar:baz is emitted, listeners for foo:bar:baz, foo:bar and foo will all be triggered.

Installation

Get it:

npm install event-box

Require it:

var EventBox = require('event-box');

API

Creation

var box = new EventBox()

Create a new EventBox.

util.inherits(MyConstructor, EventBox)

It's also possible for your own constructors to inherit from EventBox.

box.on(ev, cb, [ctx])

Register callback cb to be called when event ev is emitted, using optional this context ctx. Returns a callback that can later be passed off() to remove the listener.

box.on_c(ev, cb, [ctx])

As above but instead returns a cancellation function that can be used to remove the event listener.

box.once(ev, cb, [ctx])

Register callback cb to be called the next time event ev is emitted, using optional this context ctx. After being called once the listener is then automatically removed. Returns a callback that can later be passed off() to remove the listener.

box.once_c(ev, cb, [ctx])

As above but instead returns a cancellation function that can be used to remove the event listener.

box.off()

Remove all event bindings.

box.off(ev)

Remove all event bindings for event ev.

box.off(ev, cb)

Remove the single binding cb for event ev.

box.bind(obj, [events])

Bind all functions contained in obj as listeners for the events denoted by their respective keys. For example:

box.bind({
	foo: doFoo,
	bar: doBar
});

is equivalent to:

box.on('foo', doFoo, obj);
box.on('bar', doBar, obj);

Attached functions will be called in the context of the bound object.

The optional argument events can be used to specify the handlers which should be plucked from the supplied object, otherwise all functions found in the object will be attached.

box.bind_c(obj, [events])

As above but returns a cancellation function that can be used to remove the object binding.

box.unbind(obj)

Unbind all functions previously bound to this EventBox via call to bind().

box.emit(ev, args...)

Emit event ev with event arguments specified as successive function arguments.

box.emitArray(ev, args)

Emit event ev with event arguments specified as an array.

box.emitAfter(delay, ev, args...)

Emit event ev after delay milliseconds. Event arguments are specified as successive function arguments. Returns a function that can be used to cancel the event emission before it occurs.

box.emitEvery(interval, ev, args...)

Emit event ev every delay milliseconds. Event arguments are specified as successive function arguments. Returns a function that can be used to cancel the event emission.

Copyright & License

© 2014 Jason Frame [ @jaz303 / [email protected] ]

Released under the ISC license.