mirror of
https://github.com/fluencelabs/js-peer-id
synced 2025-04-25 12:52:14 +00:00
complement readme
This commit is contained in:
parent
9aee5bf670
commit
d7ab4bd8fb
30
README.md
30
README.md
@ -1,9 +1,9 @@
|
||||
peer-id Node.js implementation
|
||||
peer-id JavaScript implementation
|
||||
==============================
|
||||
|
||||
[](http://ipn.io) [[](http://webchat.freenode.net/?channels=%23ipfs) ](https://travis-ci.org/diasdavid/node-peer-id)  [](https://david-dm.org/diasdavid/node-peer-id) [](https://github.com/feross/standard)
|
||||
[](http://ipn.io) [[](http://webchat.freenode.net/?channels=%23ipfs) ](https://travis-ci.org/diasdavid/js-peer-id)  [](https://david-dm.org/diasdavid/js-peer-id) [](https://github.com/feross/standard)
|
||||
|
||||
> IPFS Peer Id implementation in Node.js
|
||||
> IPFS Peer Id implementation in JavaScript
|
||||
|
||||
# Description
|
||||
|
||||
@ -11,12 +11,32 @@ A IPFS Peer Id is based on a sha256 has of the peer public key, using [multihash
|
||||
|
||||
# Usage
|
||||
|
||||
### Installing
|
||||
### In Node.js through npm
|
||||
|
||||
```bash
|
||||
$ npm install --save peer-id
|
||||
```
|
||||
$ npm install peer-id
|
||||
|
||||
```javascript
|
||||
var PeerId = require('peer-id')
|
||||
```
|
||||
|
||||
### 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-id.min.js](/dist/peer-id.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 PeerId = window.PeerId
|
||||
```
|
||||
|
||||
#### Gotchas
|
||||
|
||||
You will need to use Node.js `Buffer` API compatible, if you are running inside the browser, you can access it by `PeerId.Buffer` or you can install Feross's [Buffer](https://github.com/feross/buffer).
|
||||
|
||||
### Creating a new Id
|
||||
|
||||
```
|
||||
|
@ -8,6 +8,8 @@ var keypair = require('keypair')
|
||||
|
||||
exports = module.exports = Id
|
||||
|
||||
exports.Buffer = Buffer
|
||||
|
||||
function Id (id, privKey, pubKey) {
|
||||
var self = this
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user