Running generators
co(function * () {
yield Promise.resolve(true)
}).then(...)
A generator can yield a thunk or promise. Using co() will immediately invoke the block inside it.
Generator → Promise
var fn = co.wrap(function * (val) {
return yield Promise.resolve(val)
})
fn().then(...)
Use co.wrap(). Most of the time, you’ll be using co.wrap.
0 Comments for this cheatsheet. Write yours!