0.3.7 • Published 9 years ago

@koax/compose v0.3.7

Weekly downloads
-
License
MIT
Repository
github
Last release
9 years ago

compose

Build status Git tag NPM version Code style

Compose koax middleware.

Installation

$ npm install @koax/compose

Usage

var compose = require('compose')

var composed = compose([function * (action, next) {
  if (action === 'foo') return 'bar'
  yield 'woot'
  return next()
}, function * (action, next) {
  if (action === 'bar') return 'qux'
  yield 'narf'
  return next()
}])

composed('foo')() // => 'bar' (done)
composed('bar')() // => 'woot', 'qux' (done)
composed('dup')() // => 'woot', 'narf', 'dup' (done)

API

compose(middleware)

  • middleware - compose the given middleware

Returns: a generator of the same form as the middleware

middleware

/**
 * The middleware signature
 * @param {Mixed} action   an immutable action that middleware can process
 * @param {Function} next  pass execution to next middleware (can yield or return)
 * @param {Object} ctx     the global context
 * @return {Mixed}         whatever your heart desires
 */

function * middleware (action, next, ctx) {

}

License

MIT

0.3.7

9 years ago

0.3.5

9 years ago

0.3.4

9 years ago

0.3.3

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.3

9 years ago