gocsp-channel

## Example

Usage no npm install needed!

<script type="module">
  import gocspChannel from 'https://cdn.skypack.dev/gocsp-channel';
</script>

README

gocsp-channel

Example

var co = require('gocsp-co')
var Channel = require('gocsp-channel')

var ch_0 = new Channel()
var ch_1 = new Channel()

co(function* () {

    yield ch_0.take() // => 10
    yield ch_1.take() // => 20

})()

ch_0.put(10)
ch_1.put(20)

API

new Channel()

Example:

var Channel = require('gocsp-channel')

var chan = new Channel()

channel.take()

Example:

var chan = new (require('gocsp-channel'))()

chan.take()

channel.take( callback )

Example:




channel.put( value )

Example:



channel.put( value, callback )

Example:



channel.each( fn )

Example:

channel.each(console.log)
channel.put(10) // print 10
channel.put(20) // print 20
channel.put(30) // print 30

Alias: channel.forEach

channel.close()

Example:

channel.close()
channel.close(new Error()) // close with error

channel.done( callback )

Example: