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