Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

peer-info

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

peer-info - npm Package Compare versions

Comparing version 0.5.0 to 0.5.1

2

package.json
{
"name": "peer-info",
"version": "0.5.0",
"version": "0.5.1",
"description": "IPFS Peer abstraction JavaScript implementation",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -21,9 +21,1 @@ peer-info JavaScript implementation

```
### In the Browser through `<script>` tag
Make the [peer-info.min.js](/dist/peer-info.min.js) available through your server and load it using a normal `<script>` tag, this will export the `peerId` constructor on the `window` object, such that:
```JavaScript
const PeerInfo = window.PeerInfo
```

@@ -62,4 +62,19 @@ /*

this.multiaddr.replace = (existing, fresh) => {
if (!Array.isArray(existing)) {
existing = [existing]
}
if (!Array.isArray(fresh)) {
fresh = [fresh]
}
existing.forEach((m) => {
this.multiaddr.rm(m)
})
fresh.forEach((m) => {
this.multiaddr.add(m)
})
}
// TODO: add features to fetch multiaddr using filters
// look at https://github.com/whyrusleeping/js-mafmt/blob/master/src/index.js
}

@@ -68,2 +68,29 @@ /* eslint-env mocha */

})
it('replace multiaddr', (done) => {
const pi = new PeerInfo()
expect(pi).to.exist
const mh1 = Multiaddr('/ip4/127.0.0.1/tcp/5001')
const mh2 = Multiaddr('/ip4/127.0.0.1/tcp/5002')
const mh3 = Multiaddr('/ip4/127.0.0.1/tcp/5003')
const mh4 = Multiaddr('/ip4/127.0.0.1/tcp/5004')
const mh5 = Multiaddr('/ip4/127.0.0.1/tcp/5005')
const mh6 = Multiaddr('/ip4/127.0.0.1/tcp/5006')
pi.multiaddr.add(mh1)
pi.multiaddr.add(mh2)
pi.multiaddr.add(mh3)
pi.multiaddr.add(mh4)
expect(pi.multiaddrs.length).to.equal(4)
const old = [mh2, mh4]
const fresh = [mh5, mh6]
pi.multiaddr.replace(old, fresh)
expect(pi.multiaddrs.length).to.equal(4)
done()
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc