gocsp0.1.0 • Public • Published
Bring Golang-like CSP channel to JS land.
It's based on Promise and works well with generator or async-await function.
$ npm install gocsp
Very similar to how channel works in Golang. You can take, put or select values from channels.
var co =var csp =// fromvar player = co
Create a channel. You can optional support a queue size, default is 0.
csp // without queuecsp // with queue size 2
Take a value from channel, returns a promise
Put a value into channel, return a promise
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.
Choose one of a set of take or put, timeout operations. At most one will success and rest will be cancelled.