File tree 1 file changed +5
-7
lines changed
1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -101,21 +101,19 @@ const VALID_MODES = [
101
101
* @return {ReadPreference }
102
102
*/
103
103
ReadPreference . fromOptions = function ( options ) {
104
+ if ( ! options ) return null ;
104
105
const readPreference = options . readPreference ;
106
+ if ( ! readPreference ) return null ;
105
107
const readPreferenceTags = options . readPreferenceTags ;
106
-
107
- if ( readPreference == null ) {
108
- return null ;
109
- }
110
-
108
+ const maxStalenessSeconds = options . maxStalenessSeconds ;
111
109
if ( typeof readPreference === 'string' ) {
112
110
return new ReadPreference ( readPreference , readPreferenceTags ) ;
113
111
} else if ( ! ( readPreference instanceof ReadPreference ) && typeof readPreference === 'object' ) {
114
112
const mode = readPreference . mode || readPreference . preference ;
115
113
if ( mode && typeof mode === 'string' ) {
116
114
return new ReadPreference ( mode , readPreference . tags , {
117
- maxStalenessSeconds : readPreference . maxStalenessSeconds ,
118
- hedge : options . hedge
115
+ maxStalenessSeconds : readPreference . maxStalenessSeconds || maxStalenessSeconds ,
116
+ hedge : readPreference . hedge
119
117
} ) ;
120
118
}
121
119
}
You can’t perform that action at this time.
0 commit comments