Transform a stream of Blue Chip Bridge Table Manager Protocol messages


Keywords
bridge, parser, computer, duplicate, inter-program communication
License
MIT
Install
npm install table-master-stream@1.4.1

Documentation

Table master stream

Travis build status Coverage Status npm version

table-master-stream parses and transforms a stream of Blue Chip Bridge Table Manager Protocol messages into a series of javascript objects via the node stream design pattern. It is available for Node.js and most modern browsers. If you want to know if your currrent browser is compatible, run the online test suite.

The transformed object contains a kind, text and other properties that describes the message. The message parsing is performed by table-master-parser.

The change log is automatically produced with the help of semantic-release.

Getting started

Install the latest version with npm

> npm install table-master-stream --save

Usage

Include the package

const tms = require('table-master-stream');

Process a stream

const Readable = require('stream').Readable;

// A stream of text
function text(s) {
    var s = new Readable();
    s.push(s);
    s.push(null);
    return s;
}

// Process the message
text('south plays AS')
    .pipe(tms())
    .on('data', msg => console.log(msg))
    .on('error', err => console.error(err.message));

Produces the output

{ 
    kind: 'play', 
    card: 'AS', 
    seat: 'S', 
    text: 'south plays AS' 
}

Individual messages can be acted upon. The event name is the message.kind, as in:

.on('play', msg => console.log(msg))

Browser

Include the package from your project

<script src="./node_modules/table-master-stream/dist/table-master-stream.min.js" type="text/javascript"></script>

or from the unpkg CDN

<script src="https://unpkg.com/table-master-stream/dist/table-master-stream.min.js"></script>

This will provide tableMasterStream as a global object, or define it if you are using AMD.

License

The MIT license.

Copyright © 2016 Richard Schneider (makaretu@gmail.com)