diff --git a/lib/internal/histogram.js b/lib/internal/histogram.js index ca540e555e0160..048abea57dc7ba 100644 --- a/lib/internal/histogram.js +++ b/lib/internal/histogram.js @@ -186,10 +186,7 @@ class Histogram { percentile(percentile) { if (!isHistogram(this)) throw new ERR_INVALID_THIS('Histogram'); - validateNumber(percentile, 'percentile'); - - if (NumberIsNaN(percentile) || percentile <= 0 || percentile > 100) - throw new ERR_INVALID_ARG_VALUE.RangeError('percentile', percentile); + validateNumber(percentile, 'percentile', 1, 100); return this[kHandle]?.percentile(percentile); } @@ -201,10 +198,7 @@ class Histogram { percentileBigInt(percentile) { if (!isHistogram(this)) throw new ERR_INVALID_THIS('Histogram'); - validateNumber(percentile, 'percentile'); - - if (NumberIsNaN(percentile) || percentile <= 0 || percentile > 100) - throw new ERR_INVALID_ARG_VALUE.RangeError('percentile', percentile); + validateNumber(percentile, 'percentile', 1, 100); return this[kHandle]?.percentileBigInt(percentile); } diff --git a/test/sequential/test-performance-eventloopdelay.js b/test/sequential/test-performance-eventloopdelay.js index f262e9de3fe6cb..24e5744118cc38 100644 --- a/test/sequential/test-performance-eventloopdelay.js +++ b/test/sequential/test-performance-eventloopdelay.js @@ -91,7 +91,7 @@ const { sleep } = require('internal/util'); () => histogram.percentile(i), { name: 'RangeError', - code: 'ERR_INVALID_ARG_VALUE' + code: 'ERR_OUT_OF_RANGE' } ); });