docs: function(seedlist, options) {
    var self = this;
    options = options || {};
  
    // Validate seedlist
    if (!Array.isArray(seedlist)) throw new MongoError('seedlist must be an array');
    // Validate list
    if (seedlist.length === 0) throw new MongoError('seedlist must contain at least one entry');
    // Validate entries
    seedlist.forEach(function(e) {
      if (typeof e.host !== 'string' || typeof e.port !== 'number')
        throw new MongoError('seedlist entry must contain a host and port');
    });
  
    // Add event listener
    EventEmitter.call(this);
  
    // Get replSet Id
    this.id = id++;
  
    // Get the localThresholdMS
    var localThresholdMS = options.localThresholdMS || 15;
    // Backward compatibility
    if (options.acceptableLatency) localThresholdMS = options.acceptableLatency;
  
    // Create a logger
    var logger = Logger('ReplSet', options);
  
    // Internal state
    this.s = {
      options: Object.assign({}, options),
      // BSON instance
      bson:
        options.bson ||
        new BSON([
          BSON.Binary,
          BSON.Code,
          BSON.DBRef,
          BSON.Decimal128,
          BSON.Double,
          BSON.Int32,
          BSON.Long,
          BSON.Map,
          BSON.MaxKey,
          BSON.MinKey,
          BSON.ObjectId,
          BSON.BSONRegExp,
          BSON.Symbol,
          BSON.Timestamp
        ]),
      // Factory overrides
      Cursor: options.cursorFactory || BasicCursor,
      // Logger instance
      logger: logger,
      // Seedlist
      seedlist: seedlist,
      // Replicaset state
      replicaSetState: new ReplSetState({
        id: this.id,
        setName: options.setName,
        acceptableLatency: localThresholdMS,
        heartbeatFrequencyMS: options.haInterval ? options.haInterval : 10000,
        logger: logger
      }),
      // Current servers we are connecting to
      connectingServers: [],
      // Ha interval
      haInterval: options.haInterval ? options.haInterval : 10000,
      // Minimum heartbeat frequency used if we detect a server close
      minHeartbeatFrequencyMS: 500,
      // Disconnect handler
      disconnectHandler: options.disconnectHandler,
      // Server selection index
      index: 0,
      // Connect function options passed in
      connectOptions: {},
      // Are we running in debug mode
      debug: typeof options.debug === 'boolean' ? options.debug : false,
      // Client info
      clientInfo: createClientInfo(options)
    };
  
    // Add handler for topology change
    this.s.replicaSetState.on('topologyDescriptionChanged', function(r) {
      self.emit('topologyDescriptionChanged', r);
    });
  
    // Log info warning if the socketTimeout < haInterval as it will cause
    // a lot of recycled connections to happen.
    if (
      this.s.logger.isWarn() &&
      this.s.options.socketTimeout !== 0 &&
      this.s.options.socketTimeout < this.s.haInterval
    ) {
      this.s.logger.warn(
        f(
          'warning socketTimeout %s is less than haInterval %s. This might cause unnecessary server reconnections due to socket timeouts',
          this.s.options.socketTimeout,
          this.s.haInterval
        )
      );
    }
  
    // Add forwarding of events from state handler
    var types = ['joined', 'left'];
    types.forEach(function(x) {
      self.s.replicaSetState.on(x, function(t, s) {
        self.emit(x, t, s);
      });
    });
  
    // Connect stat
    this.initialConnectState = {
      connect: false,
      fullsetup: false,
      all: false
    };
  
    // Disconnected state
    this.state = DISCONNECTED;
    this.haTimeoutId = null;
    // Last ismaster
    this.ismaster = null;
    // Contains the intervalId
    this.intervalIds = [];
  
    // Highest clusterTime seen in responses from the current deployment
    this.clusterTime = null;
  }