gocsp-go

0.0.2 • Public • Published

gocsp-go

goroutine / coroutine

Example

go(function* () {

    yield chan.take()
    yield chan.put()

    // kind of like select statement in golang
    yield select(s =>
        s(chan.take(), function (err, result) {
            if (result.done) {
                console.log('channel is closed')
            } else {
                console.log('take from channel: ' + result.value)
            }
        })
        ||
        s(chan.put(value), function (err, ok) {
            if (ok) {
                // put okk
            } else {
                // put operation failed
            }
        })
        ||
        s(timeout(1000), function () {
            console.log('timeout!!!')
        })
    )
})

API

go( generator / generatorFunction )

Example:


go.wrap( generatorFunction )

Wrap a generator function into a regular function that returns a gocsp-thunk.

Example:

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i gocsp-go

Weekly Downloads

1

Version

0.0.2

License

MIT

Last publish

Collaborators

  • gyson