Skip to content
This repository was archived by the owner on Aug 23, 2019. It is now read-only.

Commit a81c328

Browse files
actually fix things
1 parent a6ba60a commit a81c328

8 files changed

+22
-30
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@
5151
"stream-pair": "^1.0.3"
5252
},
5353
"dependencies": {
54-
"async": "^2.0.0-rc.4",
5554
"babel-runtime": "^6.6.1",
5655
"duplex-passthrough": "github:diasdavid/duplex-passthrough",
5756
"ip-address": "^5.8.0",
5857
"lodash.contains": "^2.4.3",
59-
"multistream-select": "^0.6.5",
6058
"multiaddr": "^1.4.0",
59+
"multistream-select": "^0.6.5",
6160
"peer-id": "^0.6.6",
6261
"peer-info": "^0.6.2",
63-
"protocol-buffers-stream": "^1.3.1"
62+
"protocol-buffers-stream": "^1.3.1",
63+
"run-parallel": "^1.1.6"
6464
},
6565
"aegir": {
6666
"webpack": {

src/index.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'use strict'
22

3-
const async = require('async')
43
const multistream = require('multistream-select')
54
const identify = require('./identify')
65
const DuplexPassThrough = require('duplex-passthrough')
76
const contains = require('lodash.contains')
87
const util = require('util')
98
const EE = require('events').EventEmitter
9+
const parallel = require('run-parallel')
1010

1111
exports = module.exports = Swarm
1212

@@ -378,17 +378,9 @@ function Swarm (peerInfo) {
378378
this.muxedConns[key].muxer.end()
379379
})
380380

381-
async.each(
382-
Object.keys(this.transports),
383-
(key, cb) => {
384-
// avoid unhandled error messages
385-
this.transports[key].once('error', (err) => {
386-
console.log('got error', err)
387-
})
388-
this.transports[key].close(cb)
389-
},
390-
callback
391-
)
381+
parallel(Object.keys(this.transports).map((key) => {
382+
return (cb) => this.transports[key].close(cb)
383+
}), callback)
392384
}
393385
}
394386

test/01-transport-tcp.node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
const expect = require('chai').expect
55

6-
const async = require('async')
6+
const parallel = require('run-parallel')
77
const multiaddr = require('multiaddr')
88
const Peer = require('peer-info')
99
const Swarm = require('../src')
@@ -93,7 +93,7 @@ describe('transport - tcp', function () {
9393
})
9494

9595
it('close', (done) => {
96-
async.parallel([
96+
parallel([
9797
(cb) => swarmA.transport.close('tcp', cb),
9898
(cb) => swarmB.transport.close('tcp', cb)
9999
], done)

test/03-transport-websockets.node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
const expect = require('chai').expect
55

6-
const async = require('async')
6+
const parallel = require('run-parallel')
77
const multiaddr = require('multiaddr')
88
const Peer = require('peer-info')
99
const Swarm = require('../src')
@@ -89,7 +89,7 @@ describe('transport - websockets', function () {
8989
})
9090

9191
it('close', (done) => {
92-
async.parallel([
92+
parallel([
9393
(cb) => swarmA.transport.close('ws', cb),
9494
(cb) => swarmB.transport.close('ws', cb)
9595
], done)

test/04-muxing-multiplex.node.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
const expect = require('chai').expect
55

6-
const async = require('async')
6+
const parallel = require('run-parallel')
77
const multiaddr = require('multiaddr')
88
const Peer = require('peer-info')
99
const Swarm = require('../src')
@@ -41,15 +41,15 @@ describe('stream muxing with multiplex (on TCP)', function () {
4141
swarmB.transport.add('tcp', new TCP())
4242
swarmC.transport.add('tcp', new TCP())
4343

44-
async.parallel([
44+
parallel([
4545
(cb) => swarmA.transport.listen('tcp', {}, null, cb),
4646
(cb) => swarmB.transport.listen('tcp', {}, null, cb),
4747
(cb) => swarmC.transport.listen('tcp', {}, null, cb)
4848
], done)
4949
})
5050

5151
after((done) => {
52-
async.parallel([
52+
parallel([
5353
(cb) => swarmA.close(cb),
5454
(cb) => swarmB.close(cb),
5555
(cb) => swarmC.close(cb)

test/05-muxing-spdy.node.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33

44
const expect = require('chai').expect
55

6-
const async = require('async')
6+
const parallel = require('run-parallel')
77
const multiaddr = require('multiaddr')
88
const Peer = require('peer-info')
99
const Swarm = require('../src')
1010
const TCP = require('libp2p-tcp')
1111
const spdy = require('libp2p-spdy')
1212

1313
describe('stream muxing with spdy (on TCP)', function () {
14-
this.timeout(20000)
14+
this.timeout(60 * 1000)
1515

1616
var swarmA
1717
var peerA
@@ -41,15 +41,15 @@ describe('stream muxing with spdy (on TCP)', function () {
4141
swarmB.transport.add('tcp', new TCP())
4242
swarmC.transport.add('tcp', new TCP())
4343

44-
async.parallel([
44+
parallel([
4545
(cb) => swarmA.transport.listen('tcp', {}, null, cb),
4646
(cb) => swarmB.transport.listen('tcp', {}, null, cb),
4747
(cb) => swarmC.transport.listen('tcp', {}, null, cb)
4848
], done)
4949
})
5050

5151
after((done) => {
52-
async.parallel([
52+
parallel([
5353
(cb) => swarmA.close(cb),
5454
(cb) => swarmB.close(cb),
5555
(cb) => swarmC.close(cb)

test/08-swarm-without-muxing.node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
const expect = require('chai').expect
55

6-
const async = require('async')
6+
const parallel = require('run-parallel')
77
const multiaddr = require('multiaddr')
88
const Peer = require('peer-info')
99
const Swarm = require('../src')
@@ -43,7 +43,7 @@ describe('high level API - 1st without stream multiplexing (on TCP)', function (
4343
})
4444

4545
after((done) => {
46-
async.parallel([
46+
parallel([
4747
(cb) => swarmA.close(cb),
4848
(cb) => swarmB.close(cb)
4949
], done)

test/09-swarm-with-muxing.node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
const expect = require('chai').expect
55

6-
const async = require('async')
6+
const parallel = require('run-parallel')
77
const multiaddr = require('multiaddr')
88
const Peer = require('peer-info')
99
const Swarm = require('../src')
@@ -46,7 +46,7 @@ describe('high level API - with everything mixed all together!', function () {
4646
})
4747

4848
after((done) => {
49-
async.parallel([
49+
parallel([
5050
(cb) => swarmA.close(cb),
5151
(cb) => swarmB.close(cb),
5252
// (cb) => swarmC.close(cb),

0 commit comments

Comments
 (0)