@@ -65,7 +65,7 @@ function parseFileMode(value, name, def) {
65
65
value = NumberParseInt ( value , 8 ) ;
66
66
}
67
67
68
- validateInt32 ( value , name , 0 , 2 ** 32 - 1 ) ;
68
+ validateUint32 ( value , name ) ;
69
69
return value ;
70
70
}
71
71
@@ -86,11 +86,8 @@ const validateInt32 = hideStackFrames(
86
86
if ( typeof value !== 'number' ) {
87
87
throw new ERR_INVALID_ARG_TYPE ( name , 'number' , value ) ;
88
88
}
89
- if ( ! isInt32 ( value ) ) {
90
- if ( ! NumberIsInteger ( value ) ) {
91
- throw new ERR_OUT_OF_RANGE ( name , 'an integer' , value ) ;
92
- }
93
- throw new ERR_OUT_OF_RANGE ( name , `>= ${ min } && <= ${ max } ` , value ) ;
89
+ if ( ! NumberIsInteger ( value ) ) {
90
+ throw new ERR_OUT_OF_RANGE ( name , 'an integer' , value ) ;
94
91
}
95
92
if ( value < min || value > max ) {
96
93
throw new ERR_OUT_OF_RANGE ( name , `>= ${ min } && <= ${ max } ` , value ) ;
@@ -102,16 +99,14 @@ const validateUint32 = hideStackFrames((value, name, positive) => {
102
99
if ( typeof value !== 'number' ) {
103
100
throw new ERR_INVALID_ARG_TYPE ( name , 'number' , value ) ;
104
101
}
105
- if ( ! isUint32 ( value ) ) {
106
- if ( ! NumberIsInteger ( value ) ) {
107
- throw new ERR_OUT_OF_RANGE ( name , 'an integer' , value ) ;
108
- }
109
- const min = positive ? 1 : 0 ;
110
- // 2 ** 32 === 4294967296
111
- throw new ERR_OUT_OF_RANGE ( name , `>= ${ min } && < 4294967296` , value ) ;
102
+ if ( ! NumberIsInteger ( value ) ) {
103
+ throw new ERR_OUT_OF_RANGE ( name , 'an integer' , value ) ;
112
104
}
113
- if ( positive && value === 0 ) {
114
- throw new ERR_OUT_OF_RANGE ( name , '>= 1 && < 4294967296' , value ) ;
105
+ const min = positive ? 1 : 0 ;
106
+ // 2 ** 32 === 4294967296
107
+ const max = 4_294_967_295 ;
108
+ if ( value < min || value > max ) {
109
+ throw new ERR_OUT_OF_RANGE ( name , `>= ${ min } && <= ${ max } ` , value ) ;
115
110
}
116
111
} ) ;
117
112
0 commit comments