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

@omneedia/ioredis-eventemitter

v1.0.1

Published

Redis pubsub using an event emitter via ioredis Redis client

Downloads

3

Readme

ioredis-eventemitter

Redis pubsub using an event emitter via ioredis Redis client

ioredis is a robust, performance-focused and full-featured Redis client for Node and io.js.

This work based on redis-eventemitter

##Install

	npm install ioredis-eventemitter

Usage

pub/sub clients must be compatible ioredis

var redis = require('ioredis-eventemitter');

var pubsub = redis({
	port: 6379,
	host: '127.0.0.1',
	prefix: 'production:',
	password: 'mypassword'
	// in case you want to control Redis clients
	// creation you can specify pub/sub clients pair:
	// pub: pubClient,
	// sub: subClient
});

// Listen for messages on the *:newuser channel
pubsub.on('*:newuser', function(channel, user) {
	console.log(channel); // prints "myservice:newuser"
	console.log(user);    // user is a json map as expected
});

// Publish an event "production:myservice:newuser" to the redis pubsub
pubsub.emit('myservice:newuser', { id:'a1b2c3', email:'[email protected]' });

API

.emit(channel, messages...) [publish]

var redis = require('ioredis-eventemitter');
var pubsub = redis({ prefix: 'production:' });

pubsub.emit('myservice:newuser', { id:'a1b2c3' });

.on(pattern, function(channel, messages...) { ... }) [subscribe]

var redis = require('ioredis-eventemitter');
var pubsub = redis({ prefix:'production:' });

pubsub.on('*:newuser', function(channel, message) {
	console.log(channel); // myservice:newuser
	console.log(message); // { id:'a1b2c3' }
});

.on('error', function(err) { ... }) [error handling]

To be able to handle errors (like when the redis server is down) .on('error', ...) should be used.

Note that this means that you can't listen for messages on the error channel.

.removeListener(pattern, listener)

Removes listener.

.removeAllListeners(pattern)

Removes all listeners.

Options

port

Port for the redis server. Defaults to 6379.

host

Host for the redis server. Defaults to 127.0.0.1.

password

Password for the redis server. Defaults to not being set.

prefix

A prefix that is added to the channel name, when publishing events to the redis pubsub. Useful for separating services or environments, e.g. production, development, and staging.

It is also removed when the listeners is invoked.

pub

ioredis compatible Redis client instance used for publish.

sub

ioredis compatible Redis client instance used for subscribe.