JSPM

straggler

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q25424F
  • License MIT

aggregate text streams

Package Exports

  • straggler

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (straggler) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

straggler

aggregate text streams

build status

api example

First generate keypairs for your hub, viewer, and writer rsa-json:

$ rsa-json > hub.json
$ rsa-json > viewer.json
$ rsa-json > writer.json

Create a hub and bind it to an http server:

var straggler = require('straggler');
var st = straggler(require('./hub.json'));
var hub = st.createHub(require('./authorized.json'));

var http = require('http');
var server = http.createServer(function (req, res) {
    hub.handle(req, res);
});
server.listen(5000);

Write a viewer.js program to read messages from the writer:

var straggler = require('straggler');
var st = straggler(require('./viewer.json'));
var read = st.read('http://localhost:5000');
read('writer').pipe(process.stdout);

Write a writer.js program to write messages to the hub:

var straggler = require('straggler');
var st = straggler(require('./writer.json'));
var w = st.write('http://localhost:5000');
w.end('beep boop\n');

Run the hub, the viewer, and the writer programs:

$ node hub.js &
[1] 18835
$ node viewer.js &
[2] 18840
$ node writer.js
beep boop
$ 

methods

var straggler = require('straggler')

var st = straggler(keys)

Create a new stragger instance st from keys, a public/private keypair generated by rsa-json.

var hub = st.createHub(authorized)

hub.handle(req, res)

Handle a request from a (req, res) pair from an http server.

hub.test(url)

Test a req.url string, returning the handler that should fire or undefined if the route doesn't match anything.

var reader = st.read(uri, cb)

Return a function reader to create named streams.

cb(err, keys) fires with keys, and object that maps public key strings to the user objects set up by createHub().

reader.end()

Close the connection to the hub.

reader(name)

Return a readable stream of data from the writer given by name.

st.write(uri)

Return a writable stream of data from the writer given by name.

attributes

reader.keys

populated with the authorized key data from createHub(authorized) after the connection is established

install

With npm do:

npm install straggler

license

MIT