File tree Expand file tree Collapse file tree 6 files changed +20
-27
lines changed Expand file tree Collapse file tree 6 files changed +20
-27
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ const {
100100 hideStackFrames
101101} = require ( 'internal/errors' ) ;
102102const {
103+ validateArray,
103104 validateBuffer,
104105 validateInteger,
105106 validateString
@@ -534,9 +535,7 @@ Buffer.isEncoding = function isEncoding(encoding) {
534535Buffer [ kIsEncodingSymbol ] = Buffer . isEncoding ;
535536
536537Buffer . concat = function concat ( list , length ) {
537- if ( ! ArrayIsArray ( list ) ) {
538- throw new ERR_INVALID_ARG_TYPE ( 'list' , 'Array' , list ) ;
539- }
538+ validateArray ( list , 'list' ) ;
540539
541540 if ( list . length === 0 )
542541 return new FastBuffer ( ) ;
Original file line number Diff line number Diff line change @@ -24,13 +24,11 @@ if (credentials.implementsPosixCredentials) {
2424
2525const {
2626 parseFileMode,
27+ validateArray,
2728 validateString
2829} = require ( 'internal/validators' ) ;
2930
3031function wrapPosixCredentialSetters ( credentials ) {
31- const {
32- ArrayIsArray,
33- } = primordials ;
3432 const {
3533 codes : {
3634 ERR_INVALID_ARG_TYPE ,
@@ -63,9 +61,7 @@ function wrapPosixCredentialSetters(credentials) {
6361 }
6462
6563 function setgroups ( groups ) {
66- if ( ! ArrayIsArray ( groups ) ) {
67- throw new ERR_INVALID_ARG_TYPE ( 'groups' , 'Array' , groups ) ;
68- }
64+ validateArray ( groups , 'groups' ) ;
6965 for ( let i = 0 ; i < groups . length ; i ++ ) {
7066 validateId ( groups [ i ] , `groups[${ i } ]` ) ;
7167 }
Original file line number Diff line number Diff line change @@ -29,7 +29,11 @@ const {
2929 ERR_MISSING_ARGS
3030 }
3131} = require ( 'internal/errors' ) ;
32- const { validateString, validateOneOf } = require ( 'internal/validators' ) ;
32+ const {
33+ validateArray,
34+ validateOneOf,
35+ validateString,
36+ } = require ( 'internal/validators' ) ;
3337const EventEmitter = require ( 'events' ) ;
3438const net = require ( 'net' ) ;
3539const dgram = require ( 'dgram' ) ;
@@ -377,12 +381,12 @@ ChildProcess.prototype.spawn = function(options) {
377381 validateString ( options . file , 'options.file' ) ;
378382 this . spawnfile = options . file ;
379383
380- if ( ArrayIsArray ( options . args ) )
381- this . spawnargs = options . args ;
382- else if ( options . args === undefined )
384+ if ( options . args === undefined ) {
383385 this . spawnargs = [ ] ;
384- else
385- throw new ERR_INVALID_ARG_TYPE ( 'options.args' , 'Array' , options . args ) ;
386+ } else {
387+ validateArray ( options . args , 'options.args' ) ;
388+ this . spawnargs = options . args ;
389+ }
386390
387391 const err = this . _handle . spawn ( options ) ;
388392
Original file line number Diff line number Diff line change 11'use strict' ;
22
33const {
4- ArrayIsArray,
54 ArrayPrototypeForEach,
65 ArrayPrototypeJoin,
76 ArrayPrototypeMap,
@@ -14,7 +13,7 @@ const {
1413
1514const errors = require ( 'internal/errors' ) ;
1615const { isIP } = require ( 'internal/net' ) ;
17- const { validateInt32 } = require ( 'internal/validators' ) ;
16+ const { validateArray , validateInt32 } = require ( 'internal/validators' ) ;
1817const {
1918 ChannelWrap,
2019 strerror,
@@ -60,9 +59,7 @@ class Resolver {
6059 }
6160
6261 setServers ( servers ) {
63- if ( ! ArrayIsArray ( servers ) ) {
64- throw new ERR_INVALID_ARG_TYPE ( 'servers' , 'Array' , servers ) ;
65- }
62+ validateArray ( servers , 'servers' ) ;
6663
6764 // Cache the original servers because in the event of an error while
6865 // setting the servers, c-ares won't have any servers available for
Original file line number Diff line number Diff line change 55// thread and the worker threads.
66
77const {
8- ArrayIsArray,
98 ArrayPrototypeMap,
109 ArrayPrototypePush,
1110 ArrayPrototypeSplice,
@@ -35,6 +34,7 @@ const {
3534 }
3635} = require ( 'internal/errors' ) ;
3736const format = require ( 'internal/util/inspect' ) . format ;
37+ const { validateArray } = require ( 'internal/validators' ) ;
3838const constants = internalBinding ( 'constants' ) . os . signals ;
3939
4040function assert ( x , msg ) {
@@ -55,9 +55,7 @@ function getFastAPIs(binding) {
5555 _hrtime . hrtime ( ) ;
5656
5757 if ( time !== undefined ) {
58- if ( ! ArrayIsArray ( time ) ) {
59- throw new ERR_INVALID_ARG_TYPE ( 'time' , 'Array' , time ) ;
60- }
58+ validateArray ( time , 'time' ) ;
6159 if ( time . length !== 2 ) {
6260 throw new ERR_OUT_OF_RANGE ( 'time' , 2 , time . length ) ;
6361 }
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ const {
5757} = workerIo ;
5858const { deserializeError } = require ( 'internal/error_serdes' ) ;
5959const { fileURLToPath, isURLInstance, pathToFileURL } = require ( 'internal/url' ) ;
60+ const { validateArray } = require ( 'internal/validators' ) ;
6061
6162const {
6263 ownsProcessState,
@@ -109,9 +110,7 @@ class Worker extends EventEmitter {
109110 }
110111 let argv ;
111112 if ( options . argv ) {
112- if ( ! ArrayIsArray ( options . argv ) ) {
113- throw new ERR_INVALID_ARG_TYPE ( 'options.argv' , 'Array' , options . argv ) ;
114- }
113+ validateArray ( options . argv , 'options.argv' ) ;
115114 argv = ArrayPrototypeMap ( options . argv , String ) ;
116115 }
117116
You can’t perform that action at this time.
0 commit comments