lib/sdam/server_description.js
function parseServerType(ismaster) {
  if (!ismaster || !ismaster.ok) {
    return ServerType.Unknown;
  }

  if (ismaster.isreplicaset) {
    return ServerType.RSGhost;
  }

  if (ismaster.msg && ismaster.msg === 'isdbgrid') {
    return ServerType.Mongos;
  }

  if (ismaster.setName) {
    if (ismaster.hidden) {
      return ServerType.RSOther;
    } else if (ismaster.ismaster) {
      return ServerType.RSPrimary;
    } else if (ismaster.secondary) {
      return ServerType.RSSecondary;
    } else if (ismaster.arbiterOnly) {
      return ServerType.RSArbiter;
    } else {
      return ServerType.RSOther;
    }
  }

  return ServerType.Standalone;
}
function parseServerType(ismaster) {
  if (!ismaster || !ismaster.ok) {
    return ServerType.Unknown;
  }

  if (ismaster.isreplicaset) {
    return ServerType.RSGhost;
  }

  if (ismaster.msg && ismaster.msg === 'isdbgrid') {
    return ServerType.Mongos;
  }

  if (ismaster.setName) {
    if (ismaster.hidden) {
      return ServerType.RSOther;
    } else if (ismaster.ismaster) {
      return ServerType.RSPrimary;
    } else if (ismaster.secondary) {
      return ServerType.RSSecondary;
    } else if (ismaster.arbiterOnly) {
      return ServerType.RSArbiter;
    } else {
      return ServerType.RSOther;
    }
  }

  return ServerType.Standalone;
}
function parseServerType ( ismaster ) { if ( ! ismaster || ! ismaster . ok ) { return ServerType . Unknown ; } if ( ismaster . isreplicaset ) { return ServerType . RSGhost ; } if ( ismaster . msg && ismaster . msg === 'isdbgrid' ) { return ServerType . Mongos ; } if ( ismaster . setName ) { if ( ismaster . hidden ) { return ServerType . RSOther ; } else if ( ismaster . ismaster ) { return ServerType . RSPrimary ; } else if ( ismaster . secondary ) { return ServerType . RSSecondary ; } else if ( ismaster . arbiterOnly ) { return ServerType . RSArbiter ; } else { return ServerType . RSOther ; } } return ServerType . Standalone ; }
Parses an `ismaster` message and determines the server type

@param {Object} ismaster The `ismaster` message to parse
@return {ServerType}
Parses an ismaster message and determines the server type