This repository was archived by the owner on Aug 23, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change 54
54
"stream-pair" : " ^1.0.3"
55
55
},
56
56
"dependencies" : {
57
+ "async" : " ^2.0.0-rc.4" ,
57
58
"babel-runtime" : " ^6.6.1" ,
58
59
"duplex-passthrough" : " github:diasdavid/duplex-passthrough" ,
59
60
"ip-address" : " ^5.8.0" ,
78
79
" Richard Littauer <richard.littauer@gmail.com>" ,
79
80
" dignifiedquire <dignifiedquire@gmail.com>"
80
81
]
81
- }
82
+ }
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
+ const async = require ( 'async' )
3
4
const multistream = require ( 'multistream-select' )
4
5
const identify = require ( './identify' )
5
6
const DuplexPassThrough = require ( 'duplex-passthrough' )
@@ -367,19 +368,18 @@ function Swarm (peerInfo) {
367
368
}
368
369
369
370
this . close = ( callback ) => {
370
- var count = 0
371
-
372
371
Object . keys ( this . muxedConns ) . forEach ( ( key ) => {
373
372
this . muxedConns [ key ] . muxer . end ( )
374
373
} )
375
374
376
- Object . keys ( this . transports ) . forEach ( ( key ) => {
377
- this . transports [ key ] . close ( ( ) => {
378
- if ( ++ count === Object . keys ( this . transports ) . length ) {
379
- callback ( )
380
- }
381
- } )
382
- } )
375
+ async . each (
376
+ Object . keys ( this . transports ) ,
377
+ ( key , cb ) => this . transports [ key ] . close ( cb ) ,
378
+ ( ) => {
379
+ // Ignoring close errors
380
+ callback ( )
381
+ }
382
+ )
383
383
}
384
384
}
385
385
You can’t perform that action at this time.
0 commit comments