123456789101112131415161718192021222324252627282930313233343536373839 |
- /**
- * 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){
- return function *(next){
- if (!next) next = noop();
- var i = middleware.length;
- while (i--) {
- next = middleware[i].call(this, next);
- }
- return yield *next;
- }
- }
- /**
- * Noop.
- *
- * @api private
- */
- function *noop(){}
|