complement readme

This commit is contained in:
David Dias 2015-11-05 17:47:44 +00:00
parent 9aee5bf670
commit d7ab4bd8fb
2 changed files with 27 additions and 5 deletions

View File

@ -1,9 +1,9 @@
peer-id Node.js implementation peer-id JavaScript implementation
============================== ==============================
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) ![Build Status](https://travis-ci.org/diasdavid/node-peer-id.svg?style=flat-square)](https://travis-ci.org/diasdavid/node-peer-id) ![](https://img.shields.io/badge/coverage-%3F-yellow.svg?style=flat-square) [![Dependency Status](https://david-dm.org/diasdavid/node-peer-id.svg?style=flat-square)](https://david-dm.org/diasdavid/node-peer-id) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) [![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) ![Build Status](https://travis-ci.org/diasdavid/js-peer-id.svg?style=flat-square)](https://travis-ci.org/diasdavid/js-peer-id) ![](https://img.shields.io/badge/coverage-%3F-yellow.svg?style=flat-square) [![Dependency Status](https://david-dm.org/diasdavid/js-peer-id.svg?style=flat-square)](https://david-dm.org/diasdavid/js-peer-id) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
> IPFS Peer Id implementation in Node.js > IPFS Peer Id implementation in JavaScript
# Description # Description
@ -11,12 +11,32 @@ A IPFS Peer Id is based on a sha256 has of the peer public key, using [multihash
# Usage # 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 ### Creating a new Id
``` ```

View File

@ -8,6 +8,8 @@ var keypair = require('keypair')
exports = module.exports = Id exports = module.exports = Id
exports.Buffer = Buffer
function Id (id, privKey, pubKey) { function Id (id, privKey, pubKey) {
var self = this var self = this