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