bay-compose

3.0.0 • Public • Published

bay-compose

Middleware composition utility for Bay.

NPM version

Like koa-compose@2, but:

  • returns the final value.
  • supports async function.
  • next is a yieldable function, e.g. yield * next equals yield * next().
npm i bay-compose
const compose = require('bay-compose')
 
compose([
  function * (next) {
    yield next
  },
  function * (next) {
    yield next()
  },
  function * (next) {
    yield * next
  },
  function * (next) {
    yield * next()
  },
  async function (next) {
    await next()
  },
  function (next) {
    next().then(doSomeJob)
  }
])(context)

Readme

Keywords

Package Sidebar

Install

npm i bay-compose

Weekly Downloads

3

Version

3.0.0

License

MIT

Unpacked Size

3.6 kB

Total Files

4

Last publish

Collaborators

  • chrisyipw
  • luin