@@ -62,8 +62,8 @@ const net = require('net');
62
62
const hints = ( dns . ADDRCONFIG | dns . V4MAPPED ) + 42 ;
63
63
const hintOptBlocks = doConnect ( [ { hints } ] ,
64
64
( ) => common . mustNotCall ( ) ) ;
65
- for ( const block of hintOptBlocks ) {
66
- common . expectsError ( block , {
65
+ for ( const fn of hintOptBlocks ) {
66
+ common . expectsError ( fn , {
67
67
code : 'ERR_INVALID_OPT_VALUE' ,
68
68
type : TypeError ,
69
69
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) {
136
136
function syncFailToConnect ( port , assertErr , optOnly ) {
137
137
if ( ! optOnly ) {
138
138
// 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 } )` ) ;
144
142
}
145
143
146
144
// 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')` ) ;
153
149
}
154
150
}
155
151
// 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 } })` ) ;
162
155
}
163
156
164
157
// 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 ,
169
162
assertErr ,
170
- `${ block . name } ({port: ${ port } , host: 'localhost'})` ) ;
163
+ `${ fn . name } ({port: ${ port } , host: 'localhost'})` ) ;
171
164
}
172
165
}
173
166
174
167
function canConnect ( port ) {
175
168
const noop = ( ) => common . mustCall ( ) ;
176
169
177
170
// 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 ( ) ;
181
174
}
182
175
183
176
// 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 ( ) ;
187
180
}
188
181
189
182
// 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 ( ) ;
193
186
}
194
187
195
188
// 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 ( ) ;
200
192
}
201
193
}
202
194
@@ -208,21 +200,20 @@ function asyncFailToConnect(port) {
208
200
209
201
const dont = ( ) => common . mustNotCall ( ) ;
210
202
// 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 ( ) ) ;
214
206
}
215
207
216
208
// 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 ( ) ) ;
220
212
}
221
213
222
214
// 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 ( ) ) ;
227
218
}
228
219
}
0 commit comments