simplepipes

Simple flow library based on pipes

npm install simplepipes
4 downloads in the last week
8 downloads in the last month

SimplePipes

Simple flow library based on pipes.

Installation

Via npm using (Node.js)[http://nodejs.org]:

npm install simplepipes

Usage

Reference in your program:

var simplepipes = require('simplepipes');

Define and use a flow

var flow = simplepipes.createFlow(
    "pipe1",
    function (val) {
        console.log(val);
        this.pipe2.send(val + 1);
    },
    "pipe2",
    function (val) {
        console.log(val);
        test.done();
    }
);

flow.start();
flow.pipe1.send(1);

The output:

1
2

The strings define the pipes to be used. Each function is preceded by a list of pipe names defined in the flow. Each function fires when they associated pipes have values. The values are given to the function as arguments.

You can define initial functions without associated pipes. They are fired once after starting the flow.

var flow = simplepipes.createFlow(
    function() { this.pipe1.send(1);
    "pipe1",
    function (val) {
        console.log(val);
        this.pipe2.send(val + 1);
    },
    "pipe2",
    function (val) {
        console.log(val);
        test.done();
    }
);

with the same output.

Development

git clone git://github.com/ajlopez/SimplePipes.git
cd SimplePipes
npm install
npm test

Samples

Collatz sample Collatz problem sample.

Inception

This work was inspired by Circuit by Tatumizer, but also it was based on my past years research and experiments about Go Channels and distributed applications. I had implemented in other technologies (see Channels And GoRoutines In AjSharp, GoRoutines And Channels In C#, Queue Channels In AjSharp, and now, it's time to implement something in JavaScript/Node.js.

Contribution

Feel free to file issues and submit pull requests � contributions are welcome.

If you submit a pull request, please be sure to add or update corresponding test cases, and ensure that npm test continues to pass.

npm loves you