js-csp
Communicating sequential processes for Javascript (like Clojurescript core.async, or Go).
Examples
const csp = ;
Pingpong (ported from Go).
{ while true let ball = csp; if ball === cspCLOSED console; return; ballhits += 1; console; csp; csp; } csp;
There are more under examples directory.
Documentation
This is a very close port of Clojurescript's core.async. The most significant difference
is that the IOC logic is encapsulated using generators (yield
) instead of macros. Therefore resources on core.async
or Go channels are also helpful.
Other
Or, if you use Python's Twisted: https://github.com/ubolonton/twisted-csp
Or, if you use Clojure: https://github.com/clojure/core.async
Install
npm install js-csp
bower install js-csp
Contribution
Feel free to open issues for questions/discussions, or create pull requests for improvement.
Some areas that need attention:
- More documentation, examples, and maybe some visualization. Porting RxJS/Bacon examples may help.
- Multiplexing, mixing, publishing/subscribing. These need to be tested more. The API could also be improved.
- Deadlock detection.
Development
These commands are supposed to run separately
$ npm run test:watch$ npm run lint # for code quality checking $ npm run flow:watch # to stop server after you are done run npm run flow:stop
Production
$ npm run build
It will transpile all the codes in src
to lib
, or even better if you use webpack 2
to consume
the lib via "module": "./src/csp.js"
.
Inspiration
- http://swannodette.github.io/2013/08/24/es6-generators-and-csp
- https://github.com/clojure/core.async
- https://github.com/olahol/node-csp
License
Distributed under MIT License.