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

linda-socket.io

v0.2.2

Published

Linda implementation on Socket.IO

Downloads

41

Readme

Deprecated

move to linda

Linda Socket.IO

Coordinatioin Launguage "Linda" implementation for Node.js and Socket.IO

  • https://github.com/node-linda/linda-socket.io
  • https://npmjs.org/package/linda-socket.io

Travis CI Status Badge

Install

% npm install linda-socket.io
% npm install socket.io socket.io-client

Requirements

Linda

Linda is a coordination launguage for parallel programming.

  • http://en.wikipedia.org/wiki/Linda_(coordination_language)
  • http://ja.wikipedia.org/wiki/Linda

TupleSpace

Shared memory on Node.js server.

Tuple Operations

  • write( tuple , options )
    • put a Tuple into the TupleSpace
    • options = {expire : 300} # => expire after 300 sec
  • take( tuple, callback(err, tuple) )
    • get a matched Tuple from the TupleSpace and delete
  • read( tuple, callback(err, tuple) )
    • get a matched Tuple from the TupleSpace
  • watch( tuple, callback(err, tuple) )
    • overwatch written Tuples in the TupleSpace

Samples

  • https://github.com/node-linda/linda-socket.io/tree/master/samples
  • https://github.com/node-linda/linda-job-queue-sample

Install Dependencies

% git clone https://github.com/node-linda/linda-socket.io.git
% cd linda-socket.io
% npm install
% npm install -g grunt-cli coffee-script

Chat

% coffee samples/chat/server.coffee 3000

=> http://localhost:3000

Job-Queue

% coffee samples/job-queue/server.coffee 3000

=> http://localhost:3000

print Tuple read/write/take/watch/cancel logs

% DEBUG=linda* coffee samples/chat/server.coffee 3000
% DEBUG=linda* coffee samples/job-queue/server.coffee 3000

Usage

Setup

Server Side (node.js)

var http = require('http');

var app_handler = function(req, res){
  // your web app code
};

var app = http.createServer(app_handler);

var io = require('socket.io').listen(app);

var linda = require('linda-socket.io').Linda.listen({io: io, server: app});

app.listen(3000);
console.log("server start - http://localhost:3000");

Client Side (web browser)

<script src="/socket.io/socket.io.js"></script>
<script src="/linda/linda-socket.io.js"></script>
var socket = io.connect(location.protocol+"//"+location.host);
var linda = new Linda().connect(socket);

Client Side (node.js)

var LindaClient = require('linda-socket.io').Client;
var socket = require('socket.io-client').connect('http://localhost:3000');
var linda = new LindaClient().connect(socket);

Job-Queue Sample

job client

// connect to tuplespace (shared memory)
var ts = linda.tuplespace("calc");

// request
$("#btn_request").click(function(){
  ts.write({type: "request", query: "1-2+3*4"});
});

// wait result
socket.on('connect', function(){
  // overwatch Tuple
  ts.watch({type: 'result'}, function(err, tuple){
    if(err) return;
    console.log(tuple.data.result); // => "1-2+3*4 = 11"
  });
});

job worker

// connect to tuplespace (shared memory)
var ts = linda.tuplespace("calc");

// calculate
var work = function(){
  ts.take({type: 'request'}, function(err, tuple){
    if(!err){
      var result = eval(tuple.data.query); // => "1-2+3*4"
      console.log(tuple.data.query+" = "+result); // => "1-2+3*4 = 11"
      ts.write({type: 'result', result: result}); // return to 'client' side
    }
    work(); // recursive call
  });
};

socket.on('connect', function(){ // Socket.IO's "connect" event
  work();
});

see more samples

Test

% npm install
% npm install -g grunt-cli coffee-script
% grunt test

watch

% grunt

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request