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

pnode

v0.2.5

Published

peer-to-peer dnode over anything!

Downloads

17

Readme

In progress - API Unstable!


pnode

peer-to-peer dnode over anything!

NPM version

Node tests:

Build Status

Browser tests:

browser support

Summary

pnode is a Node.js library, built ontop of dnode (What's dnode?), allows applications (node and browser) to easily communicate in a peer-to-peer fashion. Since there's no centralised server, there's no single point of failure, this ability simplifies the implementation of resilient applications by adding redundancy.

Features

  • Simplified dnode API
  • Autoreconnects and buffering like upnode
  • Easily utilise different transports
  • Usable in the browser with the Websockets transport
  • Create your own transport types with any duplex stream

Future Features

  • Client function call timeouts
  • Integration with cluster
  • Peer-to-Peer API
    • Each instance is a server and many clients
  • Authentication
    • Password
    • Certificates
    • ACL
  • Proxying RPC
    • Allowing client can communicate with server2 via server1 (clientserver1server2)
    • Achieved by expose()ing another server/client
  • WebRTC transport rtc:// to provide clientclient networks

Download

<codeBlock("npm install " + name)>

npm install pnode

Note: Only node v0.10.x is currently supported

Basic Usage

Server: <showFile("example/basic/https/server.js")>

var pnode = require('../../../');
var server = pnode.server();

server.expose({
  say: function(date) {
    console.log('client says ' + date);
  }
});

server.bind('https://0.0.0.0:8000', function(){
  console.log('bound to all interfaces on port 8000');
});

Client: <showFile("example/basic/https/client.js")>

var pnode = require('../../../');
var client = pnode.client();

client.bind('https://localhost:8000');

client.server(function(remote) {
  remote.say(new Date());
});

You can use a different transport by simply changing the URI. Currently, the following transports are avaiable:

  • tcp
  • tls
  • http
  • https
  • ipc (unix sockets)
  • ws (websockets)

See basic examples

Browser Usage

See browser examples

See this demo ('long-polling-heroku' in the examples), since Heroku doesn't support Websockets, sockjs falls back to XHR long polling with shoe maintaining stream-like behaviour.

API

See API docs

Advanced Usage

server.handle

Instead of server.listen(), you can provide the streams to server.handle():

// handle a read and write stream
foo(function(req, res) {
  server.handle(req, res);
});
// OR
// handle a duplex stream
bar(function(stream) {
  server.handle(stream);
});

Each call to server.handle() will be seen as a new client by the server.

client.createConnection

Instead of client.connect(), you can provide a function which will asynchronously create connection streams:

// create a read and a write stream
client.createConnection(function(readCallback, writeCallback) {
  readCallback(foo.createReadStream());
  writeCallback(bar.createWriteStream());
});
// OR
// create a duplex stream
client.createConnection(function(streamCallback) {
  streamCallback(bar.createStream());
});

This will get called to whenever pnode needs to restablish a connection.

<license()>

MIT License

Copyright © 2013 Jaime Pillora <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.