gocsp-channel

0.0.1 • Public • Published

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:

Readme

Keywords

none

Package Sidebar

Install

npm i gocsp-channel

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • gyson