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

Commit

Permalink
feat: expose Node class at the top level, update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Nov 28, 2016
1 parent 1d787fa commit 21ab89f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

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

> libp2p build (module) used in js-ipfs when running it on the browser.
> 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).
This libp2p build has support for:

Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const gulp = require('gulp')
const multiaddr = require('multiaddr')
const Node = require('libp2p-ipfs').Node
const Node = require('libp2p-ipfs-nodejs')
const PeerInfo = require('peer-info')
const PeerId = require('peer-id')
const pull = require('pull-stream')
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
"homepage": "https://github.com/ipfs/js-libp2p-ipfs-browser#readme",
"devDependencies": {
"aegir": "^9.1.2",
"async": "^2.1.2",
"async": "^2.1.4",
"chai": "^3.5.0",
"gulp": "^3.9.1",
"libp2p-ipfs": "^0.15.0",
"libp2p-ipfs-nodejs": "^0.16.0",
"peer-id": "^0.8.0",
"pre-commit": "^1.1.3",
"pull-goodbye": "0.0.1",
Expand All @@ -45,19 +45,19 @@
"dependencies": {
"libp2p-secio": "^0.6.3",
"libp2p-spdy": "^0.10.0",
"libp2p-swarm": "^0.26.1",
"libp2p-swarm": "^0.26.3",
"libp2p-webrtc-star": "^0.6.0",
"libp2p-websockets": "^0.9.1",
"mafmt": "^2.1.2",
"multiaddr": "^2.0.3",
"multiaddr": "^2.1.1",
"peer-book": "^0.3.0",
"peer-id": "^0.8.0",
"peer-info": "^0.8.0"
"peer-info": "^0.8.1"
},
"contributors": [
"David Dias <daviddias.p@gmail.com>",
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
"Richard Littauer <richard.littauer@gmail.com>",
"greenkeeperio-bot <support@greenkeeper.io>"
]
}
}
6 changes: 2 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const spdy = require('libp2p-spdy')
const secio = require('libp2p-secio')
const libp2p = require('libp2p')

class Node extends libp2p.Node {
class Node extends libp2p {
constructor (peerInfo, peerBook) {
const webRTCStar = new WebRTCStar()

Expand All @@ -31,6 +31,4 @@ class Node extends libp2p.Node {
}
}

module.exports = {
Node: Node
}
module.exports = Node
16 changes: 10 additions & 6 deletions test/webrtc-star-only.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const PeerId = require('peer-id')
const parallel = require('async/parallel')
const pull = require('pull-stream')

const libp2p = require('../src')
const Node = require('../src')

describe('libp2p-ipfs-browser (webrtc only)', function () {
this.timeout(15 * 1000)
Expand Down Expand Up @@ -38,15 +38,19 @@ describe('libp2p-ipfs-browser (webrtc only)', function () {
})

it('create two libp2p nodes with those peers', (done) => {
node1 = new libp2p.Node(peer1)
node2 = new libp2p.Node(peer2)
node1 = new Node(peer1)
node2 = new Node(peer2)
done()
})

it('listen on the two libp2p nodes', (done) => {
parallel([
node1.start,
node2.start
(cb) => {
node1.start(cb)
},
(cb) => {
node2.start(cb)
}
], done)
})

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

const node3 = new libp2p.Node(peer3)
const node3 = new Node(peer3)
node3.start(() => {
setTimeout(() => {
expect(Object.keys(node1.swarm.muxedConns).length).to.equal(1)
Expand Down
4 changes: 2 additions & 2 deletions test/websockets-only.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const pull = require('pull-stream')
const goodbye = require('pull-goodbye')
const serializer = require('pull-serializer')

const libp2p = require('../src')
const Node = require('../src')
const rawPeer = require('./peer.json')

describe('libp2p-ipfs-browser (websockets only)', () => {
Expand Down Expand Up @@ -39,7 +39,7 @@ describe('libp2p-ipfs-browser (websockets only)', () => {
PeerInfo.create((err, info) => {
expect(err).to.not.exist
info.multiaddr.add(multiaddr('/ip4/0.0.0.0/tcp/0'))
nodeA = new libp2p.Node(info)
nodeA = new Node(info)
done()
})
})
Expand Down

0 comments on commit 21ab89f

Please sign in to comment.