lib/ConnectSequence.js
function middlewareReducer (callSequence, middleware) {
    return function nextHandler (err) {
      // if the previous middleware passed an error argument
      if (err !== undefined) {
        if (isErrorHandler(middleware)) {
          // call the current middleware if it is an error handler middleware
          middleware(err, req, res, callSequence)
        } else {
          // else skip the current middleware and call the intermediate sequence
          callSequence(err)
        }
      } else {
        // if no error argument is passed
        if (isErrorHandler(middleware)) {
          // skip the current middleware if it is an errorHandler
          callSequence()
        } else {
          // else call it
          middleware(req, res, callSequence)
        }
      }
    }
  }
function middlewareReducer (callSequence, middleware) {
    return function nextHandler (err) {
      // if the previous middleware passed an error argument
      if (err !== undefined) {
        if (isErrorHandler(middleware)) {
          // call the current middleware if it is an error handler middleware
          middleware(err, req, res, callSequence)
        } else {
          // else skip the current middleware and call the intermediate sequence
          callSequence(err)
        }
      } else {
        // if no error argument is passed
        if (isErrorHandler(middleware)) {
          // skip the current middleware if it is an errorHandler
          callSequence()
        } else {
          // else call it
          middleware(req, res, callSequence)
        }
      }
    }
  }
function middlewareReducer ( callSequence , middleware ) { return function nextHandler ( err ) { // if the previous middleware passed an error argument if ( err !== undefined ) { if ( isErrorHandler ( middleware ) ) { // call the current middleware if it is an error handler middleware middleware ( err , req , res , callSequence ) } else { // else skip the current middleware and call the intermediate sequence callSequence ( err ) } } else { // if no error argument is passed if ( isErrorHandler ( middleware ) ) { // skip the current middleware if it is an errorHandler callSequence ( ) } else { // else call it middleware ( req , res , callSequence ) } } } }
Reduce the middleware sequence to a nested middleware handler sequence
@function
@inner
@private
@param {Function} callSequence intermediate resulting call sequence
@param {Function} middleware the current middleware
@returns {Function} the new intermediate resulting call sequence
Reduce the middleware sequence to a nested middleware handler sequence