@@ -33,7 +33,6 @@ const {
3333 ArrayPrototypeSort,
3434 ArrayPrototypeSplice,
3535 ArrayPrototypeUnshift,
36- NumberIsInteger,
3736 ObjectAssign,
3837 ObjectDefineProperty,
3938 ObjectPrototypeHasOwnProperty,
@@ -70,18 +69,19 @@ const {
7069 ERR_CHILD_PROCESS_STDIO_MAXBUFFER ,
7170 ERR_INVALID_ARG_TYPE ,
7271 ERR_INVALID_ARG_VALUE ,
73- ERR_OUT_OF_RANGE ,
7472 } ,
7573 genericNodeError,
7674} = require ( 'internal/errors' ) ;
7775const { clearTimeout, setTimeout } = require ( 'timers' ) ;
7876const { getValidatedPath } = require ( 'internal/fs/utils' ) ;
7977const {
80- isInt32,
8178 validateAbortSignal,
8279 validateArray,
8380 validateBoolean,
8481 validateFunction,
82+ validateInteger,
83+ validateInt32,
84+ validateNumber,
8585 validateObject,
8686 validateString,
8787} = require ( 'internal/validators' ) ;
@@ -603,13 +603,13 @@ function normalizeSpawnArguments(file, args, options) {
603603 }
604604
605605 // Validate the uid, if present.
606- if ( options . uid != null && ! isInt32 ( options . uid ) ) {
607- throw new ERR_INVALID_ARG_TYPE ( ' options.uid' , 'int32' , options . uid ) ;
606+ if ( options . uid != null ) {
607+ validateInt32 ( options . uid , 'options.uid' ) ;
608608 }
609609
610610 // Validate the gid, if present.
611- if ( options . gid != null && ! isInt32 ( options . gid ) ) {
612- throw new ERR_INVALID_ARG_TYPE ( ' options.gid' , 'int32' , options . gid ) ;
611+ if ( options . gid != null ) {
612+ validateInt32 ( options . gid , 'options.gid' ) ;
613613 }
614614
615615 // Validate the shell, if present.
@@ -1017,17 +1017,15 @@ function validateArgumentsNullCheck(args, propName) {
10171017
10181018
10191019function validateTimeout ( timeout ) {
1020- if ( timeout != null && ! ( NumberIsInteger ( timeout ) && timeout >= 0 ) ) {
1021- throw new ERR_OUT_OF_RANGE ( ' timeout' , 'an unsigned integer ' , timeout ) ;
1020+ if ( timeout != null ) {
1021+ validateInteger ( timeout , 'timeout ' , 0 ) ;
10221022 }
10231023}
10241024
10251025
10261026function validateMaxBuffer ( maxBuffer ) {
1027- if ( maxBuffer != null && ! ( typeof maxBuffer === 'number' && maxBuffer >= 0 ) ) {
1028- throw new ERR_OUT_OF_RANGE ( 'options.maxBuffer' ,
1029- 'a positive number' ,
1030- maxBuffer ) ;
1027+ if ( maxBuffer != null ) {
1028+ validateNumber ( maxBuffer , 'options.maxBuffer' , 0 ) ;
10311029 }
10321030}
10331031
0 commit comments