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

node-mate

v1.0.3

Published

The library for the MATE protocol

Downloads

1

Readme

node-mate

npm version Join the chat at https://gitter.im/Covertness/node-mate

node-mate is a library for the MATE protocol, written in JavaScript for node.js.

Features

Distributed

QoS

Easy-to-use

Installation

npm install node-mate

Quick start

Starting the first mate node.

var mate = require('node-mate');

var node = mate.createNode();

node.on('listening', function() {
	console.log('mate node ' + node.localNodeContact.id.toString() + ' started');
});

node.on('message', function(from, message) {
    console.log('receive ' + from.id.toString() + ' message: ' + message);
});

Starting another to connect the first node and send a message.

var mate = require('node-mate');

var node = mate.createNode({
    networkPort: 2016,
    rootNode: {
        ip: '127.0.0.1',
        port: 2015
    }
});

node.on('listening', function() {
    console.log('mate node ' + node.localNodeContact.id.toString() + ' started');
});

node.on('root_connected', function(root) {
    console.log('root node connected');

    node.send(root.id.toString(), 'I\'m here!', function(success) {
        if (success === true) {
            console.log('send message success');
        } else {
            console.log('send message failed');
        }
    });
});

You can run these code online!

API

  • mate.createNode()
  • mate.Node#send()
  • mate.Node#end()

mate.createNode([options])

Create a mate node by the given options and returns the node.

  • options is the mate node options, including:
    • networkPort: Port of the mate node listening, default 2015
    • rootNode: Address of the first connecting node when the node started, it's a object like: {ip: '127.0.0.1', port: 2015}
    • nodeId: the node id, default is a random string generated by uuid
    • nodeInfoFile: the file that stored the node id, for reuse

mate.Node#send(nodeId, message, [callback])

Send a message.

  • nodeId: the node id to send to, String
  • message: the message to send to, String, Buffer or Object
  • callback: fired on sended

mate.Node#end()

Shut down the node.

Event

  • 'listening'
  • 'root_connected'
  • 'message'
  • 'root_disconnect'
  • 'net_error'
  • 'data_error'
  • 'net_close'

'listening'

function() {}

Emitted on successful listening on the node port

'root_connected'

function(rootNode) {}

Emitted when connected to the root node

  • rootNode: Information of the root node, including id, address and so on, Object

'message'

function(fromNode, message) {}

Emitted when receive a message

  • fromNode: Information of the node that send message, including id, address and so on, Object
  • message: message of recevied, String, Buffer or Object

'root_disconnect'

function(rootNode) {}

Emitted after lost the connection with the root node

  • rootNode: Information of the root node, including id, address and so on, Object

'net_error'

function(error) {}

Emitted when the node cannot listening.

'data_error'

function(error) {}

Emitted when a parsing error occurs.

'net_close'

Emitted when the node shut down.

Code contributions

By contributing code to the project in any form, including sending a pull request via Github, a code fragment or patch via email.

License

MIT