Commit 72a743d Thomas Reggi
authored
1 parent 53cbdb0 commit 72a743d Copy full SHA for 72a743d
File tree 1 file changed +4
-6
lines changed
1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -91,20 +91,18 @@ const VALID_MODES = [
91
91
* @return {ReadPreference }
92
92
*/
93
93
ReadPreference . fromOptions = function ( options ) {
94
+ if ( ! options ) return null ;
94
95
const readPreference = options . readPreference ;
96
+ if ( readPreference == null ) return null ;
95
97
const readPreferenceTags = options . readPreferenceTags ;
96
-
97
- if ( readPreference == null ) {
98
- return null ;
99
- }
100
-
98
+ const maxStalenessSeconds = options . maxStalenessSeconds ;
101
99
if ( typeof readPreference === 'string' ) {
102
100
return new ReadPreference ( readPreference , readPreferenceTags ) ;
103
101
} else if ( ! ( readPreference instanceof ReadPreference ) && typeof readPreference === 'object' ) {
104
102
const mode = readPreference . mode || readPreference . preference ;
105
103
if ( mode && typeof mode === 'string' ) {
106
104
return new ReadPreference ( mode , readPreference . tags , {
107
- maxStalenessSeconds : readPreference . maxStalenessSeconds
105
+ maxStalenessSeconds : readPreference . maxStalenessSeconds || maxStalenessSeconds
108
106
} ) ;
109
107
}
110
108
}
You can’t perform that action at this time.
0 commit comments