aboutsummaryrefslogtreecommitdiff
path: root/node_modules/koa-compose
diff options
context:
space:
mode:
authorruki <waruqi@gmail.com>2018-11-08 00:38:48 +0800
committerruki <waruqi@gmail.com>2018-11-07 21:53:09 +0800
commit26105034da4fcce7ac883c899d781f016559310d (patch)
treec459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/koa-compose
parent2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff)
downloadxmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz
xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip
switch to vuepress
Diffstat (limited to 'node_modules/koa-compose')
-rw-r--r--node_modules/koa-compose/History.md50
-rw-r--r--node_modules/koa-compose/Readme.md40
-rw-r--r--node_modules/koa-compose/index.js52
-rw-r--r--node_modules/koa-compose/package.json36
4 files changed, 178 insertions, 0 deletions
diff --git a/node_modules/koa-compose/History.md b/node_modules/koa-compose/History.md
new file mode 100644
index 00000000..944143c7
--- /dev/null
+++ b/node_modules/koa-compose/History.md
@@ -0,0 +1,50 @@
+
+3.2.1 / 2016-10-26
+==================
+
+ * revert add variadric support #65 - introduced an unintended breaking change
+
+3.2.0 / 2016-10-25
+==================
+
+ * fix #60 infinite loop when calling next https://github.com/koajs/compose/pull/61
+ * add variadric support https://github.com/koajs/compose/pull/65
+
+3.1.0 / 2016-03-17
+==================
+
+ * add linting w/ standard
+ * use `any-promise` so that the promise engine is configurable
+
+3.0.0 / 2015-10-19
+==================
+
+ * change middleware signature to `async (ctx, next) => await next()` for `koa@2`.
+ See https://github.com/koajs/compose/pull/27 for more information.
+
+2.3.0 / 2014-05-01
+==================
+
+ * remove instrumentation
+
+2.2.0 / 2014-01-22
+==================
+
+ * add `fn._name` for debugging
+
+2.1.0 / 2013-12-22
+==================
+
+ * add debugging support
+ * improve performance ~15%
+
+2.0.1 / 2013-12-21
+==================
+
+ * update co to v3
+ * use generator delegation
+
+2.0.0 / 2013-11-07
+==================
+
+ * change middleware signature expected
diff --git a/node_modules/koa-compose/Readme.md b/node_modules/koa-compose/Readme.md
new file mode 100644
index 00000000..8fa6a392
--- /dev/null
+++ b/node_modules/koa-compose/Readme.md
@@ -0,0 +1,40 @@
+
+# koa-compose
+
+[![NPM version][npm-image]][npm-url]
+[![Build status][travis-image]][travis-url]
+[![Test coverage][codecov-image]][codecov-url]
+[![Dependency Status][david-image]][david-url]
+[![License][license-image]][license-url]
+[![Downloads][downloads-image]][downloads-url]
+
+ Compose middleware.
+
+## Installation
+
+```js
+$ npm install koa-compose
+```
+
+## API
+
+### compose([a, b, c, ...])
+
+ Compose the given middleware and return middleware.
+
+## License
+
+ MIT
+
+[npm-image]: https://img.shields.io/npm/v/koa-compose.svg?style=flat-square
+[npm-url]: https://npmjs.org/package/koa-compose
+[travis-image]: https://img.shields.io/travis/koajs/compose/next.svg?style=flat-square
+[travis-url]: https://travis-ci.org/koajs/compose
+[codecov-image]: https://img.shields.io/codecov/c/github/koajs/compose/next.svg?style=flat-square
+[codecov-url]: https://codecov.io/github/koajs/compose
+[david-image]: http://img.shields.io/david/koajs/compose.svg?style=flat-square
+[david-url]: https://david-dm.org/koajs/compose
+[license-image]: http://img.shields.io/npm/l/koa-compose.svg?style=flat-square
+[license-url]: LICENSE
+[downloads-image]: http://img.shields.io/npm/dm/koa-compose.svg?style=flat-square
+[downloads-url]: https://npmjs.org/package/koa-compose
diff --git a/node_modules/koa-compose/index.js b/node_modules/koa-compose/index.js
new file mode 100644
index 00000000..431c0ffd
--- /dev/null
+++ b/node_modules/koa-compose/index.js
@@ -0,0 +1,52 @@
+'use strict'
+
+const Promise = require('any-promise')
+
+/**
+ * Expose compositor.
+ */
+
+module.exports = compose
+
+/**
+ * Compose `middleware` returning
+ * a fully valid middleware comprised
+ * of all those which are passed.
+ *
+ * @param {Array} middleware
+ * @return {Function}
+ * @api public
+ */
+
+function compose (middleware) {
+ if (!Array.isArray(middleware)) throw new TypeError('Middleware stack must be an array!')
+ for (const fn of middleware) {
+ if (typeof fn !== 'function') throw new TypeError('Middleware must be composed of functions!')
+ }
+
+ /**
+ * @param {Object} context
+ * @return {Promise}
+ * @api public
+ */
+
+ return function (context, next) {
+ // last called middleware #
+ let index = -1
+ return dispatch(0)
+ function dispatch (i) {
+ if (i <= index) return Promise.reject(new Error('next() called multiple times'))
+ index = i
+ let fn = middleware[i]
+ if (i === middleware.length) fn = next
+ if (!fn) return Promise.resolve()
+ try {
+ return Promise.resolve(fn(context, function next () {
+ return dispatch(i + 1)
+ }))
+ } catch (err) {
+ return Promise.reject(err)
+ }
+ }
+ }
+}
diff --git a/node_modules/koa-compose/package.json b/node_modules/koa-compose/package.json
new file mode 100644
index 00000000..efc8d0d5
--- /dev/null
+++ b/node_modules/koa-compose/package.json
@@ -0,0 +1,36 @@
+{
+ "name": "koa-compose",
+ "description": "compose Koa middleware",
+ "repository": "koajs/compose",
+ "version": "3.2.1",
+ "keywords": [
+ "koa",
+ "middleware",
+ "compose"
+ ],
+ "files": [
+ "index.js"
+ ],
+ "dependencies": {
+ "any-promise": "^1.1.0"
+ },
+ "devDependencies": {
+ "co": "^4.6.0",
+ "istanbul": "^0.4.2",
+ "matcha": "^0.7.0",
+ "mocha": "^3.1.2",
+ "should": "^2.0.0",
+ "standard": "^8.4.0"
+ },
+ "scripts": {
+ "bench": "matcha bench/bench.js",
+ "lint": "standard index.js test/*.js",
+ "test": "mocha --require should --reporter spec",
+ "test-cov": "node ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --require should",
+ "test-travis": "node ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- --require should"
+ },
+ "publishConfig": {
+ "tag": "next"
+ },
+ "license": "MIT"
+}