lib/mongodb/mongodb-core/lib/topologies/mongos.js
function applyAuth(authContexts, server, callback) {
    if (authContexts.length === 0) return callback();
    // Get the first auth context
    var authContext = authContexts.shift();
    // Copy the params
    var customAuthContext = authContext.slice(0);
    // Push our callback handler
    customAuthContext.push(function(/* err */) {
      applyAuth(authContexts, server, callback);
    });

    // Attempt authentication
    server.auth.apply(server, customAuthContext);
  }
function applyAuth(authContexts, server, callback) {
    if (authContexts.length === 0) return callback();
    // Get the first auth context
    var authContext = authContexts.shift();
    // Copy the params
    var customAuthContext = authContext.slice(0);
    // Push our callback handler
    customAuthContext.push(function(/* err */) {
      applyAuth(authContexts, server, callback);
    });

    // Attempt authentication
    server.auth.apply(server, customAuthContext);
  }
function applyAuth ( authContexts , server , callback ) { if ( authContexts . length === 0 ) return callback ( ) ; // Get the first auth context var authContext = authContexts . shift ( ) ; // Copy the params var customAuthContext = authContext . slice ( 0 ) ; // Push our callback handler customAuthContext . push ( function ( /* err */ ) { applyAuth ( authContexts , server , callback ) ; } ) ; // Attempt authentication server . auth . apply ( server , customAuthContext ) ; }
Apply one of the contexts
Apply one of the contexts