File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change 22
33const { ERR_INVALID_OPT_VALUE } = require ( 'internal/errors' ) . codes ;
44
5+ function highWaterMarkFrom ( options , isDuplex , duplexKey ) {
6+ return options . highWaterMark != null ? options . highWaterMark :
7+ isDuplex ? options [ duplexKey ] : null ;
8+ }
9+
510function getHighWaterMark ( state , options , duplexKey , isDuplex ) {
6- let hwm = options . highWaterMark ;
11+ const hwm = highWaterMarkFrom ( options , isDuplex , duplexKey ) ;
712 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 ) ;
1716 }
17+ return Math . floor ( hwm ) ;
1818 }
1919
2020 // Default value
You can’t perform that action at this time.
0 commit comments