| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2ffb9d6 commit 36e5100
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -63,18 +63,22 @@ function validateInteger(value, name) { | |||
| 63 | 63 | } | |
| 64 | 64 | ||
| 65 | 65 | function validateInt32(value, name, min = -2147483648, max = 2147483647) { | |
| 66 | + // The defaults for min and max correspond to the limits of 32-bit integers. | ||
| 66 | 67 | if (!isInt32(value)) { | |
| 67 | 68 | let err; | |
| 68 | 69 | if (typeof value !== 'number') { | |
| 69 | 70 | err = new ERR_INVALID_ARG_TYPE(name, 'number', value); | |
| 70 | 71 | } else if (!Number.isInteger(value)) { | |
| 71 | 72 | err = new ERR_OUT_OF_RANGE(name, 'an integer', value); | |
| 72 | 73 | } else { | |
| 73 | - // 2 ** 31 === 2147483648 | ||
| 74 | - err = new ERR_OUT_OF_RANGE(name, '> -2147483649 && < 2147483648', value); | ||
| 74 | + err = new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value); | ||
| 75 | 75 | } | |
| 76 | 76 | Error.captureStackTrace(err, validateInt32); | |
| 77 | 77 | throw err; | |
| 78 | + } else if (value < min || value > max) { | ||
| 79 | + const err = new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value); | ||
| 80 | + Error.captureStackTrace(err, validateInt32); | ||
| 81 | + throw err; | ||
| 78 | 82 | } | |
| 79 | 83 | } | |
| 80 | 84 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments