peer-info
Advanced tools
Comparing version 0.3.3 to 0.4.0
{ | ||
"name": "peer-info", | ||
"version": "0.3.3", | ||
"description": "IPFS Peer abstraction Node.js implementation", | ||
"version": "0.4.0", | ||
"description": "IPFS Peer abstraction JavaScript implementation", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"test": "./node_modules/.bin/lab tests/*-test.js", | ||
"coverage": "./node_modules/.bin/lab -t 100 tests/*-test.js", | ||
"codestyle": "./node_modules/.bin/standard --format", | ||
"lint": "jshint .", | ||
"validate": "npm ls" | ||
"test:node": "node tests/*-test.js", | ||
"lint": "standard", | ||
"test": "npm run test:node", | ||
"test:browser": "./node_modules/.bin/zuul --browser-version $BROWSER_VERSION --browser-name $BROWSER_NAME -- tests/peer-test.js", | ||
"test:browser:q": "BROWSER_VERSION=46 BROWSER_NAME=chrome npm run test:browser", | ||
"build": "./node_modules/.bin/browserify -s PeerInfo -e ./src/index.js | tee dist/peer-info.js | ./node_modules/.bin/uglifyjs -m > dist/peer-info.min.js" | ||
}, | ||
@@ -21,3 +22,3 @@ "repository": { | ||
"engines": { | ||
"node": "^4.0.0" | ||
"node": "^4.2.0" | ||
}, | ||
@@ -31,14 +32,14 @@ "author": "David Dias <daviddias@ipfs.io>", | ||
"pre-commit": [ | ||
"codestyle", | ||
"lint", | ||
"test" | ||
], | ||
"devDependencies": { | ||
"code": "^1.4.1", | ||
"lab": "^5.13.0", | ||
"multiaddr": "^1.1.1", | ||
"peer-id": "^0.4.0", | ||
"pre-commit": "^1.1.1", | ||
"standard": "^4.5.2" | ||
"standard": "^4.5.2", | ||
"tape": "^4.2.2", | ||
"zuul": "^3.7.2" | ||
}, | ||
"dependencies": { | ||
"peer-id": "^0.3.0" | ||
} | ||
"dependencies": {} | ||
} |
@@ -6,3 +6,2 @@ peer-info JavaScript implementation | ||
> IPFS Peer abstraction JavaScript implementation | ||
@@ -13,1 +12,28 @@ | ||
# Usage | ||
### In Node.js through npm | ||
```bash | ||
$ npm install --save peer-info | ||
``` | ||
```javascript | ||
var PeerInfo = require('peer-info') | ||
``` | ||
### In the Browser through browserify | ||
Same as in Node.js, you just have to [browserify](https://github.com/substack/node-browserify) the code before serving it. See the browserify repo for how to do that. | ||
### 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 | ||
var PeerInfo = window.PeerInfo | ||
``` | ||
#### Gotchas | ||
You will need to use Node.js `Buffer` API compatible, if you are running inside the browser, you can access it by `PeerInfo.Buffer` or you can install Feross's [Buffer](https://github.com/feross/buffer). | ||
@@ -5,4 +5,2 @@ /* | ||
var PeerId = require('peer-id') | ||
exports = module.exports = Peer | ||
@@ -17,4 +15,4 @@ | ||
if (!(id instanceof PeerId)) { | ||
throw new Error('Peer must be created with an instance of PeerId') | ||
if (!Array.isArray(multiaddrs)) { | ||
multiaddrs = [multiaddrs] | ||
} | ||
@@ -21,0 +19,0 @@ |
@@ -0,1 +1,12 @@ | ||
var test = require('tape') | ||
var PeerId = require('peer-id') | ||
var Multiaddr = require('multiaddr') | ||
var PeerInfo = require('../src') | ||
test('test creation', function (t) { | ||
var id = PeerId.create() | ||
var mh = Multiaddr('/ip4/127.0.0.1/tcp/5001') | ||
var pi = new PeerInfo(id, mh) | ||
t.ok(pi) | ||
t.end() | ||
}) |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
7553
0
11
43
38
6
2
4
- Removedpeer-id@^0.3.0
- Removedbs58@2.0.1(transitive)
- Removedbuffer-equal@0.0.1(transitive)
- Removedinvert-hash@0.0.0(transitive)
- Removedmultihashes@0.1.3(transitive)
- Removedmultihashing@0.1.3(transitive)
- Removedpeer-id@0.3.4(transitive)