cojs

0.0.2 • Public • Published

Cojs

This Library is heavily inspired by

clojure.core.async.

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

  1. enable switch statement support in act expressions
  2. enable continue/break in act expressions
  3. enable finally clause in try expressions.
  4. test, test, test

Package Sidebar

Install

npm i cojs

Weekly Downloads

4

Version

0.0.2

License

ISC

Last publish

Collaborators

  • francesco_bracchi