1.1.0 • Published 10 years ago
@f/channel v1.1.0
channel
Simple CSP channel implemented with promises.
Installation
$ npm install @f/channelUsage
import channel from '@f/channel'
let {take, put} = channel()
take().then(val => val) // => 42
put(42).then(val => val) // => trueAPI
channel()
Returns: bound channel methods
take()
Returns: promise that resolves to a value that is put on channel
put(value)
value- value to put
Returns: promise that resolves to true or false indicating whetehr value is taken
close()
Close the channel. All pending takes resolve to CLOSED. All pending puts resolve to false.
open()
Open the channel. Open a closed channel.
CLOSED
Closed value.
License
MIT