Comparing version 0.5.0 to 0.5.1
{ | ||
"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() | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9421
194
0
21