@@ -148,7 +148,7 @@ Manager.prototype.allocate = function allocate(fn) {
148
148
/**
149
149
* Two helper functions that allows us to correctly call the callback with
150
150
* the correct arguments when we generate a new connection as the connection
151
- * should be emitting 'connect' befor we can use it. But it can also emit
151
+ * should be emitting 'connect' before we can use it. But it can also emit
152
152
* error if it fails to connect, or times in so doing.
153
153
*
154
154
* @param {Error } err Optional error argument.
@@ -166,6 +166,11 @@ Manager.prototype.allocate = function allocate(fn) {
166
166
fn ( err , this ) ;
167
167
}
168
168
169
+ /**
170
+ * Listen to timeout events.
171
+ *
172
+ * @api private
173
+ */
169
174
function timeout ( ) {
170
175
this . removeListener ( 'timeout' , timeout ) ;
171
176
self . pending -- ;
@@ -204,7 +209,7 @@ Manager.prototype.allocate = function allocate(fn) {
204
209
// we didn't find a confident match, see if we are allowed to generate a fresh
205
210
// connection
206
211
if ( ( this . pool . length + this . pending ) < this . limit ) {
207
- // determin if the function expects a callback or not, this can be done by
212
+ // determine if the function expects a callback or not, this can be done by
208
213
// checking the length of the given function, as the amount of args accepted
209
214
// equals the length..
210
215
if ( this . generator . length === 0 ) {
@@ -213,9 +218,10 @@ Manager.prototype.allocate = function allocate(fn) {
213
218
if ( connection ) {
214
219
this . pending ++ ;
215
220
this . listen ( connection ) ;
221
+
216
222
connection . on ( 'error' , either )
217
- . on ( 'connect' , either )
218
- . on ( 'timeout' , timeout ) ;
223
+ . on ( 'connect' , either )
224
+ . on ( 'timeout' , timeout ) ;
219
225
220
226
return this ;
221
227
}
@@ -226,9 +232,10 @@ Manager.prototype.allocate = function allocate(fn) {
226
232
227
233
self . pending ++ ;
228
234
self . listen ( connection ) ;
235
+
229
236
return connection . on ( 'error' , either )
230
- . on ( 'connect' , either )
231
- . on ( 'timeout' , timeout ) ;
237
+ . on ( 'connect' , either )
238
+ . on ( 'timeout' , timeout ) ;
232
239
} ) ;
233
240
}
234
241
}
@@ -283,7 +290,7 @@ Manager.prototype.isAvailable = function isAvailable(net, ignore) {
283
290
// The connection is still opening, so we can write to it in the future.
284
291
if ( readyState === 'opening' ) return 70 ;
285
292
286
- // We have some writes, so we are going to substract that amount from our 100.
293
+ // We have some writes, so we are going to subtract that amount from our 100.
287
294
if ( writes < 100 ) return 100 - writes ;
288
295
289
296
// We didn't find any reliable states of the stream, so we are going to
0 commit comments