@@ -62,8 +62,8 @@ const net = require('net');
6262 const hints = ( dns . ADDRCONFIG | dns . V4MAPPED ) + 42 ;
6363 const hintOptBlocks = doConnect ( [ { hints } ] ,
6464 ( ) => common . mustNotCall ( ) ) ;
65- for ( const block of hintOptBlocks ) {
66- common . expectsError ( block , {
65+ for ( const fn of hintOptBlocks ) {
66+ common . expectsError ( fn , {
6767 code : 'ERR_INVALID_OPT_VALUE' ,
6868 type : TypeError ,
6969 message : / T h e v a l u e " \d + " i s i n v a l i d f o r o p t i o n " h i n t s " /
@@ -136,67 +136,59 @@ function doConnect(args, getCb) {
136136function syncFailToConnect ( port , assertErr , optOnly ) {
137137 if ( ! optOnly ) {
138138 // connect(port, cb) and connect(port)
139- const portArgBlocks = doConnect ( [ port ] , ( ) => common . mustNotCall ( ) ) ;
140- for ( const block of portArgBlocks ) {
141- assert . throws ( block ,
142- assertErr ,
143- `${ block . name } (${ port } )` ) ;
139+ const portArgFunctions = doConnect ( [ port ] , ( ) => common . mustNotCall ( ) ) ;
140+ for ( const fn of portArgFunctions ) {
141+ assert . throws ( fn , assertErr , `${ fn . name } (${ port } )` ) ;
144142 }
145143
146144 // connect(port, host, cb) and connect(port, host)
147- const portHostArgBlocks = doConnect ( [ port , 'localhost' ] ,
148- ( ) => common . mustNotCall ( ) ) ;
149- for ( const block of portHostArgBlocks ) {
150- assert . throws ( block ,
151- assertErr ,
152- `${ block . name } (${ port } , 'localhost')` ) ;
145+ const portHostArgFunctions = doConnect ( [ port , 'localhost' ] ,
146+ ( ) => common . mustNotCall ( ) ) ;
147+ for ( const fn of portHostArgFunctions ) {
148+ assert . throws ( fn , assertErr , `${ fn . name } (${ port } , 'localhost')` ) ;
153149 }
154150 }
155151 // connect({port}, cb) and connect({port})
156- const portOptBlocks = doConnect ( [ { port } ] ,
157- ( ) => common . mustNotCall ( ) ) ;
158- for ( const block of portOptBlocks ) {
159- assert . throws ( block ,
160- assertErr ,
161- `${ block . name } ({port: ${ port } })` ) ;
152+ const portOptFunctions = doConnect ( [ { port } ] , ( ) => common . mustNotCall ( ) ) ;
153+ for ( const fn of portOptFunctions ) {
154+ assert . throws ( fn , assertErr , `${ fn . name } ({port: ${ port } })` ) ;
162155 }
163156
164157 // connect({port, host}, cb) and connect({port, host})
165- const portHostOptBlocks = doConnect ( [ { port : port , host : 'localhost' } ] ,
166- ( ) => common . mustNotCall ( ) ) ;
167- for ( const block of portHostOptBlocks ) {
168- assert . throws ( block ,
158+ const portHostOptFunctions = doConnect ( [ { port : port , host : 'localhost' } ] ,
159+ ( ) => common . mustNotCall ( ) ) ;
160+ for ( const fn of portHostOptFunctions ) {
161+ assert . throws ( fn ,
169162 assertErr ,
170- `${ block . name } ({port: ${ port } , host: 'localhost'})` ) ;
163+ `${ fn . name } ({port: ${ port } , host: 'localhost'})` ) ;
171164 }
172165}
173166
174167function canConnect ( port ) {
175168 const noop = ( ) => common . mustCall ( ) ;
176169
177170 // connect(port, cb) and connect(port)
178- const portArgBlocks = doConnect ( [ port ] , noop ) ;
179- for ( const block of portArgBlocks ) {
180- block ( ) ;
171+ const portArgFunctions = doConnect ( [ port ] , noop ) ;
172+ for ( const fn of portArgFunctions ) {
173+ fn ( ) ;
181174 }
182175
183176 // connect(port, host, cb) and connect(port, host)
184- const portHostArgBlocks = doConnect ( [ port , 'localhost' ] , noop ) ;
185- for ( const block of portHostArgBlocks ) {
186- block ( ) ;
177+ const portHostArgFunctions = doConnect ( [ port , 'localhost' ] , noop ) ;
178+ for ( const fn of portHostArgFunctions ) {
179+ fn ( ) ;
187180 }
188181
189182 // connect({port}, cb) and connect({port})
190- const portOptBlocks = doConnect ( [ { port } ] , noop ) ;
191- for ( const block of portOptBlocks ) {
192- block ( ) ;
183+ const portOptFunctions = doConnect ( [ { port } ] , noop ) ;
184+ for ( const fn of portOptFunctions ) {
185+ fn ( ) ;
193186 }
194187
195188 // connect({port, host}, cb) and connect({port, host})
196- const portHostOptBlocks = doConnect ( [ { port : port , host : 'localhost' } ] ,
197- noop ) ;
198- for ( const block of portHostOptBlocks ) {
199- block ( ) ;
189+ const portHostOptFns = doConnect ( [ { port, host : 'localhost' } ] , noop ) ;
190+ for ( const fn of portHostOptFns ) {
191+ fn ( ) ;
200192 }
201193}
202194
@@ -208,21 +200,20 @@ function asyncFailToConnect(port) {
208200
209201 const dont = ( ) => common . mustNotCall ( ) ;
210202 // connect(port, cb) and connect(port)
211- const portArgBlocks = doConnect ( [ port ] , dont ) ;
212- for ( const block of portArgBlocks ) {
213- block ( ) . on ( 'error' , onError ( ) ) ;
203+ const portArgFunctions = doConnect ( [ port ] , dont ) ;
204+ for ( const fn of portArgFunctions ) {
205+ fn ( ) . on ( 'error' , onError ( ) ) ;
214206 }
215207
216208 // connect({port}, cb) and connect({port})
217- const portOptBlocks = doConnect ( [ { port } ] , dont ) ;
218- for ( const block of portOptBlocks ) {
219- block ( ) . on ( 'error' , onError ( ) ) ;
209+ const portOptFunctions = doConnect ( [ { port } ] , dont ) ;
210+ for ( const fn of portOptFunctions ) {
211+ fn ( ) . on ( 'error' , onError ( ) ) ;
220212 }
221213
222214 // connect({port, host}, cb) and connect({port, host})
223- const portHostOptBlocks = doConnect ( [ { port : port , host : 'localhost' } ] ,
224- dont ) ;
225- for ( const block of portHostOptBlocks ) {
226- block ( ) . on ( 'error' , onError ( ) ) ;
215+ const portHostOptFns = doConnect ( [ { port, host : 'localhost' } ] , dont ) ;
216+ for ( const fn of portHostOptFns ) {
217+ fn ( ) . on ( 'error' , onError ( ) ) ;
227218 }
228219}
0 commit comments