Skip to content
This repository was archived by the owner on Apr 29, 2020. It is now read-only.

Commit 21ab89f

Browse files
committed
feat: expose Node class at the top level, update deps
1 parent 1d787fa commit 21ab89f

File tree

6 files changed

+22
-20
lines changed

6 files changed

+22
-20
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
[![Sauce Test Status](https://saucelabs.com/browser-matrix/libp2p-ipfs-browser.svg)](https://saucelabs.com/u/libp2p-ipfs-browser)
1616

17-
> libp2p build (module) used in js-ipfs when running it on the browser.
17+
> libp2p build (module) used in js-ipfs when running it on the browser. If you are looking for the version to be used in Node.js, see [libp2p-ipfs-nodejs](https://github.com/ipfs/js-libp2p-ipfs-nodejs).
1818
1919
This libp2p build has support for:
2020

gulpfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const gulp = require('gulp')
44
const multiaddr = require('multiaddr')
5-
const Node = require('libp2p-ipfs').Node
5+
const Node = require('libp2p-ipfs-nodejs')
66
const PeerInfo = require('peer-info')
77
const PeerId = require('peer-id')
88
const pull = require('pull-stream')

package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
"homepage": "https://github.com/ipfs/js-libp2p-ipfs-browser#readme",
3232
"devDependencies": {
3333
"aegir": "^9.1.2",
34-
"async": "^2.1.2",
34+
"async": "^2.1.4",
3535
"chai": "^3.5.0",
3636
"gulp": "^3.9.1",
37-
"libp2p-ipfs": "^0.15.0",
37+
"libp2p-ipfs-nodejs": "^0.16.0",
3838
"peer-id": "^0.8.0",
3939
"pre-commit": "^1.1.3",
4040
"pull-goodbye": "0.0.1",
@@ -45,19 +45,19 @@
4545
"dependencies": {
4646
"libp2p-secio": "^0.6.3",
4747
"libp2p-spdy": "^0.10.0",
48-
"libp2p-swarm": "^0.26.1",
48+
"libp2p-swarm": "^0.26.3",
4949
"libp2p-webrtc-star": "^0.6.0",
5050
"libp2p-websockets": "^0.9.1",
5151
"mafmt": "^2.1.2",
52-
"multiaddr": "^2.0.3",
52+
"multiaddr": "^2.1.1",
5353
"peer-book": "^0.3.0",
5454
"peer-id": "^0.8.0",
55-
"peer-info": "^0.8.0"
55+
"peer-info": "^0.8.1"
5656
},
5757
"contributors": [
5858
"David Dias <[email protected]>",
5959
"Friedel Ziegelmayer <[email protected]>",
6060
"Richard Littauer <[email protected]>",
6161
"greenkeeperio-bot <[email protected]>"
6262
]
63-
}
63+
}

src/index.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const spdy = require('libp2p-spdy')
66
const secio = require('libp2p-secio')
77
const libp2p = require('libp2p')
88

9-
class Node extends libp2p.Node {
9+
class Node extends libp2p {
1010
constructor (peerInfo, peerBook) {
1111
const webRTCStar = new WebRTCStar()
1212

@@ -31,6 +31,4 @@ class Node extends libp2p.Node {
3131
}
3232
}
3333

34-
module.exports = {
35-
Node: Node
36-
}
34+
module.exports = Node

test/webrtc-star-only.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const PeerId = require('peer-id')
88
const parallel = require('async/parallel')
99
const pull = require('pull-stream')
1010

11-
const libp2p = require('../src')
11+
const Node = require('../src')
1212

1313
describe('libp2p-ipfs-browser (webrtc only)', function () {
1414
this.timeout(15 * 1000)
@@ -38,15 +38,19 @@ describe('libp2p-ipfs-browser (webrtc only)', function () {
3838
})
3939

4040
it('create two libp2p nodes with those peers', (done) => {
41-
node1 = new libp2p.Node(peer1)
42-
node2 = new libp2p.Node(peer2)
41+
node1 = new Node(peer1)
42+
node2 = new Node(peer2)
4343
done()
4444
})
4545

4646
it('listen on the two libp2p nodes', (done) => {
4747
parallel([
48-
node1.start,
49-
node2.start
48+
(cb) => {
49+
node1.start(cb)
50+
},
51+
(cb) => {
52+
node2.start(cb)
53+
}
5054
], done)
5155
})
5256

@@ -114,7 +118,7 @@ describe('libp2p-ipfs-browser (webrtc only)', function () {
114118
node2.dialByPeerInfo(peerInfo, () => {})
115119
})
116120

117-
const node3 = new libp2p.Node(peer3)
121+
const node3 = new Node(peer3)
118122
node3.start(() => {
119123
setTimeout(() => {
120124
expect(Object.keys(node1.swarm.muxedConns).length).to.equal(1)

test/websockets-only.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const pull = require('pull-stream')
1010
const goodbye = require('pull-goodbye')
1111
const serializer = require('pull-serializer')
1212

13-
const libp2p = require('../src')
13+
const Node = require('../src')
1414
const rawPeer = require('./peer.json')
1515

1616
describe('libp2p-ipfs-browser (websockets only)', () => {
@@ -39,7 +39,7 @@ describe('libp2p-ipfs-browser (websockets only)', () => {
3939
PeerInfo.create((err, info) => {
4040
expect(err).to.not.exist
4141
info.multiaddr.add(multiaddr('/ip4/0.0.0.0/tcp/0'))
42-
nodeA = new libp2p.Node(info)
42+
nodeA = new Node(info)
4343
done()
4444
})
4545
})

0 commit comments

Comments
 (0)