Communication Sequential Processes in Javascript
Bring Golang-like CSP channel to JS land.
It's based on Promise and works well with generator or async-await function.
Installation
$ npm install gocsp
Usage
Very similar to how channel works in Golang. You can take, put or select values from channels.
var co = var csp = // from http://talks.golang.org/2013/advconc.slide#6 var player = co
API
csp.chan(size)
Create a channel. You can optional support a queue size, default is 0.
csp // without queue csp // with queue size 2
csp.take(ch)
Take a value from channel, returns a promise
csp
csp.put(ch, value)
Put a value into channel, return a promise
csp
csp.close(ch)
Close a channel. When channel is closed, you cannot put values into it anymore. You may still be able to take remaining queued values from channel.
csp
csp.select(fn)
Choose one of a set of take or put, timeout operations. At most one will success and rest will be cancelled.
csp
License
MIT