lib/router/index.js
function param(err) {
    if (err) {
      return done(err);
    }

    if (i >= keys.length ) {
      return done();
    }

    paramIndex = 0;
    key = keys[i++];
    name = key.name;
    paramVal = req.params[name];
    paramCallbacks = params[name];
    paramCalled = called[name];

    if (paramVal === undefined || !paramCallbacks) {
      return param();
    }

    // param previously called with same value or error occurred
    if (paramCalled && (paramCalled.match === paramVal
      || (paramCalled.error && paramCalled.error !== 'route'))) {
      // restore value
      req.params[name] = paramCalled.value;

      // next param
      return param(paramCalled.error);
    }

    called[name] = paramCalled = {
      error: null,
      match: paramVal,
      value: paramVal
    };

    paramCallback();
  }
function param(err) {
    if (err) {
      return done(err);
    }

    if (i >= keys.length ) {
      return done();
    }

    paramIndex = 0;
    key = keys[i++];
    name = key.name;
    paramVal = req.params[name];
    paramCallbacks = params[name];
    paramCalled = called[name];

    if (paramVal === undefined || !paramCallbacks) {
      return param();
    }

    // param previously called with same value or error occurred
    if (paramCalled && (paramCalled.match === paramVal
      || (paramCalled.error && paramCalled.error !== 'route'))) {
      // restore value
      req.params[name] = paramCalled.value;

      // next param
      return param(paramCalled.error);
    }

    called[name] = paramCalled = {
      error: null,
      match: paramVal,
      value: paramVal
    };

    paramCallback();
  }
function param ( err ) { if ( err ) { return done ( err ) ; } if ( i >= keys . length ) { return done ( ) ; } paramIndex = 0 ; key = keys [ i ++ ] ; name = key . name ; paramVal = req . params [ name ] ; paramCallbacks = params [ name ] ; paramCalled = called [ name ] ; if ( paramVal === undefined || ! paramCallbacks ) { return param ( ) ; } // param previously called with same value or error occurred if ( paramCalled && ( paramCalled . match === paramVal || ( paramCalled . error && paramCalled . error !== 'route' ) ) ) { // restore value req . params [ name ] = paramCalled . value ; // next param return param ( paramCalled . error ) ; } called [ name ] = paramCalled = { error : null , match : paramVal , value : paramVal } ; paramCallback ( ) ; }
process params in order param callbacks can be async
process params in order param callbacks can be async