From 26105034da4fcce7ac883c899d781f016559310d Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 8 Nov 2018 00:38:48 +0800 Subject: switch to vuepress --- node_modules/koa-compose/History.md | 50 +++++++++++++++++++++++++++++++++ node_modules/koa-compose/Readme.md | 40 +++++++++++++++++++++++++++ node_modules/koa-compose/index.js | 52 +++++++++++++++++++++++++++++++++++ node_modules/koa-compose/package.json | 36 ++++++++++++++++++++++++ 4 files changed, 178 insertions(+) create mode 100644 node_modules/koa-compose/History.md create mode 100644 node_modules/koa-compose/Readme.md create mode 100644 node_modules/koa-compose/index.js create mode 100644 node_modules/koa-compose/package.json (limited to 'node_modules/koa-compose') 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" +} -- cgit v1.2.3