File tree 1 file changed +10
-10
lines changed
1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change 2
2
3
3
const { ERR_INVALID_OPT_VALUE } = require ( 'internal/errors' ) . codes ;
4
4
5
+ function highWaterMarkFrom ( options , isDuplex , duplexKey ) {
6
+ return options . highWaterMark != null ? options . highWaterMark :
7
+ isDuplex ? options [ duplexKey ] : null ;
8
+ }
9
+
5
10
function getHighWaterMark ( state , options , duplexKey , isDuplex ) {
6
- let hwm = options . highWaterMark ;
11
+ const hwm = highWaterMarkFrom ( options , isDuplex , duplexKey ) ;
7
12
if ( hwm != null ) {
8
- if ( typeof hwm !== 'number' || ! ( hwm >= 0 ) )
9
- throw new ERR_INVALID_OPT_VALUE ( 'highWaterMark' , hwm ) ;
10
- return Math . floor ( hwm ) ;
11
- } else if ( isDuplex ) {
12
- hwm = options [ duplexKey ] ;
13
- if ( hwm != null ) {
14
- if ( typeof hwm !== 'number' || ! ( hwm >= 0 ) )
15
- throw new ERR_INVALID_OPT_VALUE ( duplexKey , hwm ) ;
16
- return Math . floor ( hwm ) ;
13
+ if ( ! Number . isInteger ( hwm ) || hwm < 0 ) {
14
+ const name = isDuplex ? duplexKey : 'highWaterMark' ;
15
+ throw new ERR_INVALID_OPT_VALUE ( name , hwm ) ;
17
16
}
17
+ return Math . floor ( hwm ) ;
18
18
}
19
19
20
20
// Default value
You can’t perform that action at this time.
0 commit comments