22
33const {
44 MapPrototypeEntries,
5- NumberIsInteger ,
5+ NumberIsNaN ,
66 NumberMAX_SAFE_INTEGER,
77 ObjectFromEntries,
88 ReflectConstruct,
@@ -185,7 +185,9 @@ class Histogram {
185185 percentile ( percentile ) {
186186 if ( ! isHistogram ( this ) )
187187 throw new ERR_INVALID_THIS ( 'Histogram' ) ;
188- validateNumber ( percentile , 'percentile' , 1 , 100 ) ;
188+ validateNumber ( percentile , 'percentile' ) ;
189+ if ( NumberIsNaN ( percentile ) || percentile <= 0 || percentile > 100 )
190+ throw new ERR_OUT_OF_RANGE ( 'percentile' , '> 0 && <= 100' , percentile ) ;
189191
190192 return this [ kHandle ] ?. percentile ( percentile ) ;
191193 }
@@ -197,7 +199,9 @@ class Histogram {
197199 percentileBigInt ( percentile ) {
198200 if ( ! isHistogram ( this ) )
199201 throw new ERR_INVALID_THIS ( 'Histogram' ) ;
200- validateNumber ( percentile , 'percentile' , 1 , 100 ) ;
202+ validateNumber ( percentile , 'percentile' ) ;
203+ if ( NumberIsNaN ( percentile ) || percentile <= 0 || percentile > 100 )
204+ throw new ERR_OUT_OF_RANGE ( 'percentile' , '> 0 && <= 100' , percentile ) ;
201205
202206 return this [ kHandle ] ?. percentileBigInt ( percentile ) ;
203207 }
@@ -277,11 +281,7 @@ class RecordableHistogram extends Histogram {
277281 return ;
278282 }
279283
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 ) ;
284+ validateInteger ( val , 'val' , 1 ) ;
285285
286286 this [ kHandle ] ?. record ( val ) ;
287287 }
0 commit comments