gocsp-co
Coroutine in js world
Example
var co = var thunk = 1 2 { }
Difference with TJ's co
co()
in gocsp-co will return a wrapper function which will return a thunk when called, where tj's co use last argument as callback (it's also a thunk if no other arguments).
Async Function
Use it as ES7 async function.
Example:
{ return co}
API Reference
co( generator_function )
Return a wrapper function which will return a thunk when called.
Example:
1 2 { }
co.spawn( generator_function / generator )
Return a thunk. If argument is generator function, it will be called (e.g. genFun()
) and returned generator will be used for coroutine.
Example:
// with a generatorco { } // with a generator functionvar x = 1 y = 2co { }
co.limit( num, generator_function )
Example:
co // gocsp-each // limit total number of connectionhttp
Inspiration
Licence
MIT