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

zyre

v0.0.5

Published

Zyre

Downloads

8

Readme

Zyre binding for Node.js

Prerequisites

This is not a pre-built module. Sorry. Before running "npm install" you must build/install libsodium, libzmq, libczmq, and libzyre. Frankly it's simpler to build/install without using npm:

mkdir -p $HOME/temp
cd $HOME/temp
git clone https://github.com/zeromq/zyre
cd zyre/bindings/nodejs
./build.sh

And then copy build/Release/zyre.node to the node_modules/ directory of whatever application you want to tey it in.

Quick Start

This package wraps the Zyre library for Node.js. Here is an example of use:

var ZyreBinding = require ('bindings')('zyre');
var zyre = new ZyreBinding.Zyre ();
console.log ("Create Zyre node, uuid=" + zyre.uuid () + " name=" + zyre.name ());

zyre.start ();
zyre.join ("GLOBAL");
zyre.print ();

while (true) {
    var event = new ZyreBinding.ZyreEvent (zyre);
    if (!event.defined ())
        break;              //  Interrupted
    event.print ();

    if (event.type_name () == "ENTER") {
        //  If new peer, say hello to it and wait for it to answer us
        console.log ("[" + event.peer_name () + "] peer entered");
        zyre.whisper (event.peer_uuid (), "Hello");
    }
    else
    if (event.type_name () == "EXIT") {
        console.log ("[" + event.peer_name () + "] peer exited");
    }
    else
    if (event.type_name () == "WHISPER") {
        console.log ("[" + event.peer_name () + "] received ping (WHISPER)");
        zyre.shout ("GLOBAL", "Hello");
    }
    else
    if (event.type_name () == "SHOUT") {
        console.log ("[" + event.peer_name () + "]("
                  + event.group () + ") received ping (SHOUT)");
    }
    event.destroy ();
}
zyre.stop ();
zyre.destroy ();

Implementation

This is a wrapping of the native C libzyre library. See binding.cc for the code.

We get two classes:

Zyre        - a Zyre node instance
ZyreEvent   - an event from the Zyre network

The Zyre class has these methods:

destroy
defined
uuid
name
start
stop
setHeader (name, value)
setVerbose
join (group)
leave (group)
print
whisper (peer_uuid, message)
shout (group, message)
recv

The ZyreEvent class has these methods:

destroy
defined
type
type_name
peer_uuid
peer_name
peer_addr
header (name)
group
msg
print

Building from Source

  • You need Python (v2.7 recommended, v3.x not supported)
  • You need (ideally) nvm and Node.js.
  • If your Linux has an existing 'node' command, remove it. You need matching versions of node and node-gyp.
  • In every terminal, or .bashrc: nvm use v5.5.0

To install the necessary Node tools:

sudo apt-get update
sudo apt-get install build-essential libssl-dev
curl https://raw.githubusercontent.com/creationix/nvm/v0.11.1/install.sh | bash
# close terminal, re-open
nvm ls-remote
nvm install v5.5.0
npm install -g node-gyp
npm install -g node-pre-gyp

To build (in theory):

mkdir -p $HOME/temp
cd $HOME/temp
git clone https://github.com/zeromq/zyre
cd zyre/bindings/nodejs
./build.sh

Making Changes

Note that this version of the binding is destined for destruction; we will replace it with one generated via zproject, with essentially the same API.

Having said that, fixes and improvements are welcome. Please send your pull requests to https://github.com/zeromq/zyre.