cojs / composition

create compositions of generator functions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Composition

Create compositions of middleware just like koa-compose. However, this is for general usage, not specifically for koa. In particular:

  • No debug instrumentation
  • Returns the value of the first middleware.

Use this to create your own middleware platforms.

Example

var compose = require('composition')

co(function* () {
  var fns = []
  fns.push(function* (next) {
    return yield* next
  })
  fns.push(function* () {
    return this
  })

  var fn = compose(fns)

  var res = yield* fn.call(true)
  // => true
  // because of `return this`
})

About

create compositions of generator functions

License:MIT License


Languages

Language:JavaScript 100.0%