GeezerVison is showing github.com — perf_hooks: throw ERR_INVALID_ARG_VALUE if histogram.percentile param… · nodejs/node@327a2b7
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/histogram.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
5 | 5 | } = require('internal/util'); |
6 | 6 |
|
7 | 7 | const { format } = require('util'); |
8 | | -const { SafeMap, Symbol } = primordials; |
| 8 | +const { NumberIsNaN, SafeMap, Symbol } = primordials; |
9 | 9 |
|
10 | 10 | const { |
11 | 11 | ERR_INVALID_ARG_TYPE, |
@@ -61,7 +61,7 @@ class Histogram { |
61 | 61 | if (typeof percentile !== 'number') |
62 | 62 | throw new ERR_INVALID_ARG_TYPE('percentile', 'number', percentile); |
63 | 63 |
|
64 | | - if (percentile <= 0 || percentile > 100) |
| 64 | + if (NumberIsNaN(percentile) || percentile <= 0 || percentile > 100) |
65 | 65 | throw new ERR_INVALID_ARG_VALUE.RangeError('percentile', percentile); |
66 | 66 |
|
67 | 67 | return this[kHandle]?.percentile(percentile); |
|
Collapse file
Copy file name to clipboardExpand all lines: test/sequential/test-performance-eventloopdelay.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -86,7 +86,7 @@ const { sleep } = require('internal/util'); |
86 | 86 | } |
87 | 87 | ); |
88 | 88 | }); |
89 | | - [-1, 0, 101].forEach((i) => { |
| 89 | + [-1, 0, 101, NaN].forEach((i) => { |
90 | 90 | assert.throws( |
91 | 91 | () => histogram.percentile(i), |
92 | 92 | { |
|