This Library is heavily inspired by
and the Haskell mvars;
This library doesn't make use generators or promises, but a walker is implemented, that rewrites fork blocks, thanks to sweetjs macro system
Install sweetjs
npm install -g sweetjs
npm install cojs
sjs -m cojs/macros <file>.js
var mvar = require('cojs/mvar');
var ch = mvar(),
m = 80000,
n = 0;
fork {
while (true) {
var v <~ ch;
console.log ('received 1: ' + v);
}
}
fork {
while (true) {
var v <~ ch;
console.log ('received 2: ' + v);
}
}
fork {
while (n < m) {
ch ~> n;
console.log ('sent: ' + n);
n++;
}
}
Some more examples are implemented in the /examples dir
wrapper around a channel that throws an error if the returned value is an instanceof Error
- enable switch statement support in action expressions
- enable continue/break in action expressions
- test, test, test