Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormawaregetsuka <33221990+mawaregetsuka@users.noreply.github.com>2022-04-03 01:57:44 +0300
committerGitHub <noreply@github.com>2022-04-03 01:57:44 +0300
commit302fd02f7140ff06d511eaae807944e335682177 (patch)
treef2d334a7735595a0e6e926f064138e4055ba37b4 /lib
parent7c8d98ea84fc298c5c1d3e84985e3f9b3f861691 (diff)
lib: improve the coverage of the validator
PR-URL: https://github.com/nodejs/node/pull/42443 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/validators.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/internal/validators.js b/lib/internal/validators.js
index b07eebfbd8b..e3584aaf2e1 100644
--- a/lib/internal/validators.js
+++ b/lib/internal/validators.js
@@ -82,10 +82,10 @@ const validateInteger = hideStackFrames(
const validateInt32 = hideStackFrames(
(value, name, min = -2147483648, max = 2147483647) => {
// The defaults for min and max correspond to the limits of 32-bit integers.
+ if (typeof value !== 'number') {
+ throw new ERR_INVALID_ARG_TYPE(name, 'number', value);
+ }
if (!isInt32(value)) {
- if (typeof value !== 'number') {
- throw new ERR_INVALID_ARG_TYPE(name, 'number', value);
- }
if (!NumberIsInteger(value)) {
throw new ERR_OUT_OF_RANGE(name, 'an integer', value);
}
@@ -98,10 +98,10 @@ const validateInt32 = hideStackFrames(
);
const validateUint32 = hideStackFrames((value, name, positive) => {
+ if (typeof value !== 'number') {
+ throw new ERR_INVALID_ARG_TYPE(name, 'number', value);
+ }
if (!isUint32(value)) {
- if (typeof value !== 'number') {
- throw new ERR_INVALID_ARG_TYPE(name, 'number', value);
- }
if (!NumberIsInteger(value)) {
throw new ERR_OUT_OF_RANGE(name, 'an integer', value);
}