Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Wrap koa-like generators to express-like callbacks.
var co = require('co')
/**
* Wrap koa-like generators to express-like callbacks.
*
* @param {GeneratorFunction} fn
* @return {Function}
*/
modules.exports = function wrap(fn) {
return function(req, res, next) {
co(function*() {
yield* fn(req, res)
})
.catch(next)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.