node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org »

bacon-trans

npm version

bacon-trans

Stream chaining library like a transducers for Bacon.js.

Getting it

Installation for node projects

npm install --save baconjs
npm install --save bacon-trans

and load in your node programs.

var Bacon = require('baconjs');
var t = require('bacon-trans');

Load for web browser.

<script src="bacon-trans-web.js"></script>
<script>
var Bacon = require('baconjs');
var t = require('bacon-trans');
</script>

usage

Basic

// combination of method and callback can be assigned to valiables.
var square = t.map(function(x){ return x*x; }); 
var isEven = t.filter(function(x){ return x%2 === 0; }); 
var log    = t.onValue(console,'log');
 
// create stream
var stream = t(square, isEven, log);
 
var arr = new Bacon.fromArray([1,2,3,4,5,6,7,8,9]);
 
// applying
stream(arr);
 
// reuse stream any number of times.
var arr2 = new Bacon.fromArray([11,12,13,14,15,16,17,18,19,20]);
stream(arr2);
 
// create stream of another combination
var stream2 = t(isEven, square);
 
// joining stream
var stream3 = t(stream2, log);
 
var arr3 = new Bacon.fromArray([1,2,3,4,5,6,7,8,9]);
 
// applying
stream3(arr3);