22
33const {
44 MapPrototypeEntries,
5+ NumberIsNaN,
56 NumberIsInteger,
67 NumberMAX_SAFE_INTEGER,
78 ObjectFromEntries,
@@ -185,7 +186,9 @@ class Histogram {
185186 percentile ( percentile ) {
186187 if ( ! isHistogram ( this ) )
187188 throw new ERR_INVALID_THIS ( 'Histogram' ) ;
188- validateNumber ( percentile , 'percentile' , 1 , 100 ) ;
189+ validateNumber ( percentile , 'percentile' ) ;
190+ if ( NumberIsNaN ( percentile ) || percentile <= 0 || percentile > 100 )
191+ throw new ERR_OUT_OF_RANGE ( 'percentile' , '> 0 && <= 100' , percentile ) ;
189192
190193 return this [ kHandle ] ?. percentile ( percentile ) ;
191194 }
@@ -197,7 +200,9 @@ class Histogram {
197200 percentileBigInt ( percentile ) {
198201 if ( ! isHistogram ( this ) )
199202 throw new ERR_INVALID_THIS ( 'Histogram' ) ;
200- validateNumber ( percentile , 'percentile' , 1 , 100 ) ;
203+ validateNumber ( percentile , 'percentile' ) ;
204+ if ( NumberIsNaN ( percentile ) || percentile <= 0 || percentile > 100 )
205+ throw new ERR_OUT_OF_RANGE ( 'percentile' , '> 0 && <= 100' , percentile ) ;
201206
202207 return this [ kHandle ] ?. percentileBigInt ( percentile ) ;
203208 }
@@ -277,11 +282,7 @@ class RecordableHistogram extends Histogram {
277282 return ;
278283 }
279284
280- if ( ! NumberIsInteger ( val ) )
281- throw new ERR_INVALID_ARG_TYPE ( 'val' , [ 'integer' , 'bigint' ] , val ) ;
282-
283- if ( val < 1 || val > NumberMAX_SAFE_INTEGER )
284- throw new ERR_OUT_OF_RANGE ( 'val' , 'a safe integer greater than 0' , val ) ;
285+ validateInteger ( val , 'val' , 1 ) ;
285286
286287 this [ kHandle ] ?. record ( val ) ;
287288 }
0 commit comments