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

mesh-socket-io-bus

v1.1.4

Published

[![Build Status](https://travis-ci.org/mojo-js/mesh-socket.io.svg)](https://travis-ci.org/mojo-js/mesh-socket.io) [![Coverage Status](https://coveralls.io/repos/mojo-js/mesh-socket.io/badge.svg?branch=master)](https://coveralls.io/r/mojo-js/mesh-socket.io

Downloads

35

Readme

Build Status Coverage Status Dependency Status

Streams for socket.io. Also works with mesh.

Basic example

var mesh = require("mesh");
var loki = require("mesh-loki");
var io   = require("mesh-socket.io");

var bus = mesh.tailable(loki());

// setup socket io - take all remote ops and pass
// to the bus
var iobus = mesh.reject("load", io({
  host: "http://localhost"
}, bus));

// pipe all actions on bus to socket.io
bus(mesh.op("tail")).pipe(mesh.open(iobus));

// insert data into the DB. Should get broadcasted
// to socket.io
bus(mesh.op("insert", {
  collection: "people"
  data: {
    name: "Shrek"
  }
}));

server configuration

Server configuration is pretty easy to setup. Just re-broadcast incomming actions.

var io = require("socket.io");
var server = io(80);
server.on("connection", function(connection) {

  // note that "action" is the channel that the client is
  // publishing / subscribing to
  connection.on("action", function(action) {

    // re-broadcast to other clients
    connection.broadcast.emit("action", action);
  });
});

db(options, bus)

creates a new socket.io streamer.

  • options
    • host - socket.io server host
    • channel - channel to subscribe to. Default is action.
  • bus - bus to pass remote calls to
var iodb = io({
  host: "http://localhost",
  channel: "myactionsChannel"
})

stream.Readable db(actionName, options)

Broadcasts a new action. This can be anything.

stream.Readable db(tail, filter)

Tails a remote action.


// tail all actions
db(mesh.op("tail")).on("data", function() {

});

// tail only insert actions
db(mesh.op("tail", { name: "insert" })).on("data", function() {

});

// tail only actions on people collection
db(mesh.op("tail", { collection: "people" })).on("data", function() {

});