diff --git a/lib/internal/histogram.js b/lib/internal/histogram.js index ca540e555e0160..782e1970d53b03 100644 --- a/lib/internal/histogram.js +++ b/lib/internal/histogram.js @@ -2,7 +2,6 @@ const { MapPrototypeEntries, - NumberIsNaN, NumberIsInteger, NumberMAX_SAFE_INTEGER, ObjectFromEntries, @@ -186,10 +185,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 +197,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' } ); });