diff --git a/lib/internal/histogram.js b/lib/internal/histogram.js index ca540e555e0160..92a679e8f3a634 100644 --- a/lib/internal/histogram.js +++ b/lib/internal/histogram.js @@ -36,7 +36,6 @@ const { validateInteger, validateNumber, validateObject, - validateUint32, } = require('internal/validators'); const kDestroy = Symbol('kDestroy'); @@ -368,7 +367,7 @@ function createHistogram(options = kEmptyObject) { } else if (highest < 2n * lowest) { throw new ERR_INVALID_ARG_VALUE.RangeError('options.highest', highest); } - validateUint32(figures, 'options.figures', 1, 5); + validateInteger(figures, 'options.figures', 1, 5); return internalRecordableHistogram(new _Histogram(lowest, highest, figures)); } diff --git a/test/parallel/test-perf-hooks-histogram.js b/test/parallel/test-perf-hooks-histogram.js index 1bcc59653bb692..37fcdfb3fca06c 100644 --- a/test/parallel/test-perf-hooks-histogram.js +++ b/test/parallel/test-perf-hooks-histogram.js @@ -135,6 +135,13 @@ const { inspect } = require('util'); }); }); + // Number greater than 5 is not allowed + for (const i of [6, 10]) { + throws(() => createHistogram({ figures: i }), { + code: 'ERR_OUT_OF_RANGE', + }); + } + createHistogram({ lowest: 1, highest: 11, figures: 1 }); }