File tree 3 files changed +7
-5
lines changed
3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ const utils = require('../../lib/utils');
39
39
function AggregationCursor ( agg ) {
40
40
const streamOpts = { objectMode : true } ;
41
41
// for node < 12 we will emit 'close' event after 'end'
42
- if ( utils . nodeMajorVersion >= 12 ) {
42
+ if ( utils . nodeMajorVersion ( ) >= 12 ) {
43
43
// set autoDestroy=true because on node 12 it's by default false
44
44
// gh-10902 need autoDestroy to destroy correctly and emit 'close' event for node >= 12
45
45
streamOpts . autoDestroy = true ;
@@ -95,7 +95,7 @@ AggregationCursor.prototype._read = function() {
95
95
return _this . emit ( 'error' , error ) ;
96
96
}
97
97
// for node >= 12 the autoDestroy will emit the 'close' event
98
- if ( utils . nodeMajorVersion < 12 ) {
98
+ if ( utils . nodeMajorVersion ( ) < 12 ) {
99
99
_this . on ( 'end' , ( ) => _this . emit ( 'close' ) ) ;
100
100
}
101
101
} ) ;
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ const utils = require('../../lib/utils');
37
37
function QueryCursor ( query , options ) {
38
38
const streamOpts = { objectMode : true } ;
39
39
// for node < 12 we will emit 'close' event after 'end'
40
- if ( utils . nodeMajorVersion >= 12 ) {
40
+ if ( utils . nodeMajorVersion ( ) >= 12 ) {
41
41
// set autoDestroy=true because on node 12 it's by default false
42
42
// gh-10902 need autoDestroy to destroy correctly and emit 'close' event for node >= 12
43
43
streamOpts . autoDestroy = true ;
@@ -104,7 +104,7 @@ QueryCursor.prototype._read = function() {
104
104
return _this . emit ( 'error' , error ) ;
105
105
}
106
106
// for node >= 12 the autoDestroy will emit the 'close' event
107
- if ( utils . nodeMajorVersion < 12 ) {
107
+ if ( utils . nodeMajorVersion ( ) < 12 ) {
108
108
_this . on ( 'end' , ( ) => _this . emit ( 'close' ) ) ;
109
109
}
110
110
} ) ;
Original file line number Diff line number Diff line change @@ -936,4 +936,6 @@ exports.errorToPOJO = function errorToPOJO(error) {
936
936
return ret ;
937
937
} ;
938
938
939
- exports . nodeMajorVersion = parseInt ( process . versions . node . split ( '.' ) [ 0 ] , 10 ) ;
939
+ exports . nodeMajorVersion = function nodeMajorVersion ( ) {
940
+ return parseInt ( process . versions . node . split ( '.' ) [ 0 ] , 10 ) ;
941
+ } ;
You can’t perform that action at this time.
0 commit comments