cojs
v0.0.2
Published
goroutines for javascript
Downloads
6
Maintainers
Readme
Cojs
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 macros
Install
Prerequisites
Install sweetjs
npm install -g sweetjs
Install
npm install cojs
Use
sjs -m cojs/macros <file>.js
example
var mvar = require('cojs/mvar');
var ch = mvar(),
m = 80000,
n = 0;
fork {
while (true) {
val v = ?ch;
console.log ('received 1: ' + v);
}
}
fork {
while (true) {
val 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
TODO
features to be completed
- enable switch statement support in act expressions
- enable continue/break in act expressions
- enable finally clause in try expressions.
- test, test, test