@@ -75,6 +75,7 @@ const {
7575    ERR_SOCKET_CLOSED 
7676  } 
7777}  =  require ( 'internal/errors' ) ; 
78+ const  {  validateNumber }  =  require ( 'internal/validators' ) ; 
7879const  {  utcDate }  =  require ( 'internal/http' ) ; 
7980const  {  onServerStream, 
8081        Http2ServerRequest, 
@@ -1001,8 +1002,7 @@ class Http2Session extends EventEmitter {
10011002    if  ( this . destroyed ) 
10021003      throw  new  ERR_HTTP2_INVALID_SESSION ( ) ; 
10031004
1004-     if  ( typeof  id  !==  'number' ) 
1005-       throw  new  ERR_INVALID_ARG_TYPE ( 'id' ,  'number' ,  id ) ; 
1005+     validateNumber ( id ,  'id' ) ; 
10061006    if  ( id  <=  0  ||  id  >  kMaxStreams ) 
10071007      throw  new  ERR_OUT_OF_RANGE ( 'id' ,  `> 0 and <= ${ kMaxStreams }  ,  id ) ; 
10081008    this [ kHandle ] . setNextStreamID ( id ) ; 
@@ -1144,12 +1144,8 @@ class Http2Session extends EventEmitter {
11441144                                     [ 'Buffer' ,  'TypedArray' ,  'DataView' ] , 
11451145                                     opaqueData ) ; 
11461146    } 
1147-     if  ( typeof  code  !==  'number' )  { 
1148-       throw  new  ERR_INVALID_ARG_TYPE ( 'code' ,  'number' ,  code ) ; 
1149-     } 
1150-     if  ( typeof  lastStreamID  !==  'number' )  { 
1151-       throw  new  ERR_INVALID_ARG_TYPE ( 'lastStreamID' ,  'number' ,  lastStreamID ) ; 
1152-     } 
1147+     validateNumber ( code ,  'code' ) ; 
1148+     validateNumber ( lastStreamID ,  'lastStreamID' ) ; 
11531149
11541150    const  goawayFn  =  submitGoaway . bind ( this ,  code ,  lastStreamID ,  opaqueData ) ; 
11551151    if  ( this . connecting )  { 
@@ -1831,8 +1827,7 @@ class Http2Stream extends Duplex {
18311827  // close, it is still possible to queue up PRIORITY and RST_STREAM frames, 
18321828  // but no DATA and HEADERS frames may be sent. 
18331829  close ( code  =  NGHTTP2_NO_ERROR ,  callback )  { 
1834-     if  ( typeof  code  !==  'number' ) 
1835-       throw  new  ERR_INVALID_ARG_TYPE ( 'code' ,  'number' ,  code ) ; 
1830+     validateNumber ( code ,  'code' ) ; 
18361831    if  ( code  <  0  ||  code  >  kMaxInt ) 
18371832      throw  new  ERR_OUT_OF_RANGE ( 'code' ,  `>= 0 && <= ${ kMaxInt }  ,  code ) ; 
18381833    if  ( callback  !==  undefined  &&  typeof  callback  !==  'function' ) 
@@ -2326,8 +2321,7 @@ class ServerHttp2Stream extends Http2Stream {
23262321      this [ kState ] . flags  |=  STREAM_FLAGS_HAS_TRAILERS ; 
23272322    } 
23282323
2329-     if  ( typeof  fd  !==  'number' ) 
2330-       throw  new  ERR_INVALID_ARG_TYPE ( 'fd' ,  'number' ,  fd ) ; 
2324+     validateNumber ( fd ,  'fd' ) ; 
23312325
23322326    debug ( `Http2Stream ${ this [ kID ] }   + 
23332327          `${ sessionName ( session [ kType ] ) }  ) ; 
0 commit comments