{"name":"peer-info","version":"0.6.0","description":"IPFS Peer abstraction JavaScript implementation","main":"src/index.js","scripts":{"lint":"standard","test":"npm run test:node && npm run test:browser","test:node":"mocha tests/*-test.js","test:browser":"karma start karma.conf.js","coverage":"istanbul cover --print both -- _mocha tests/*-test.js"},"repository":{"type":"git","url":"git+https://github.com/diasdavid/js-peer-info.git"},"keywords":["IPFS"],"engines":{"node":"^4.3.0"},"author":{"name":"David Dias","email":"daviddias@ipfs.io"},"license":"MIT","bugs":{"url":"https://github.com/diasdavid/js-peer-info/issues"},"homepage":"https://github.com/diasdavid/js-peer-info","pre-commit":["lint","test"],"devDependencies":{"buffer-loader":"0.0.1","chai":"^3.5.0","istanbul":"^0.4.2","json-loader":"^0.5.4","karma":"^0.13.19","karma-chrome-launcher":"^0.2.2","karma-cli":"^0.1.2","karma-firefox-launcher":"^0.1.7","karma-mocha":"^0.2.1","karma-spec-reporter":"0.0.24","karma-webpack":"^1.7.0","mocha":"^2.4.5","multiaddr":"^1.1.1","peer-id":"^0.6.0","pre-commit":"^1.1.2","standard":"^6.0.7","webpack":"^1.12.14"},"dependencies":{},"gitHead":"c579fc6c9c19def60541cb4625f020bd132ea6a0","_id":"peer-info@0.6.0","_shasum":"99ddb05e1f15027edd126c3d6d71fdd072a2e6f9","_from":".","_npmVersion":"2.14.20","_nodeVersion":"4.4.0","_npmUser":{"name":"daviddias","email":"daviddias.p@gmail.com"},"maintainers":[{"name":"daviddias","email":"daviddias.p@gmail.com"}],"dist":{"shasum":"99ddb05e1f15027edd126c3d6d71fdd072a2e6f9","tarball":"http://registry-npm.ywwl.com/peer-info/download/peer-info-0.6.0.tgz","integrity":"sha512-/EOFncuB9R5SerAIk364khf62W7GjiBtmvP95TQO9EIx6RuFzJ8jPF+0I6ABg2eRwvqZQ0HzDIE6QAR15UIjcg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA/yxS1AT33ti7EuOkDXJXRrXYsIFpTkpRO0+A0/No8UAiEArErL3isw5AJL84VPZbOTD3nUEEc4UXyKJuwdA/BUyyE="}],"size":3715,"noattachment":false,"key":"/peer-info/-/peer-info-0.6.0.tgz"},"_npmOperationalInternal":{"host":"packages-13-west.internal.npmjs.com","tmp":"tmp/peer-info-0.6.0.tgz_1457639269491_0.03145615430548787"},"directories":{},"deprecated":"No longer supported for js-libp2p0.28.0 or later","readme":"# js-peer-info\n\n[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai)\n[![](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)\n[![](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)\n[![Discourse posts](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg)](https://discuss.libp2p.io)\n[![](https://img.shields.io/codecov/c/github/libp2p/js-peer-info.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-peer-info)\n[![](https://img.shields.io/travis/libp2p/js-peer-info.svg?style=flat-square)](https://travis-ci.com/libp2p/js-peer-info)\n[![Dependency Status](https://david-dm.org/libp2p/js-peer-info.svg?style=flat-square)](https://david-dm.org/libp2p/js-peer-info)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)\n![](https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square)\n![](https://img.shields.io/badge/Node.js-%3E%3D6.0.0-orange.svg?style=flat-square)\n\n## Lead Maintainer\n\n[Vasco Santos](https://github.com/vasco-santos)\n\n## Table of Contents\n\n- [js-peer-info](#js-peer-info)\n  - [Lead Maintainer](#lead-maintainer)\n  - [Table of Contents](#table-of-contents)\n  - [Installation](#installation)\n    - [npm](#npm)\n    - [Node.JS, Browserify, Webpack](#nodejs-browserify-webpack)\n    - [Browser: `<script>` Tag](#browser-script-tag)\n  - [Usage](#usage)\n  - [API](#api)\n    - [`PeerInfo.create([id])`](#peerinfocreateid)\n    - [`new PeerInfo(id)`](#new-peerinfoid)\n    - [`.id`](#id)\n    - [`protocols`](#protocols)\n    - [`.protocols.add(protocol)`](#protocolsaddprotocol)\n    - [`.protocols.delete(protocol)`](#protocolsdeleteprotocol)\n    - [`.multiaddrs`](#multiaddrs)\n    - [`.multiaddrs.add(addr)`](#multiaddrsaddaddr)\n    - [`.multiaddrs.addSafe(addr)`](#multiaddrsaddsafeaddr)\n    - [`.multiaddrs.delete(addr)`](#multiaddrsdeleteaddr)\n    - [`.multiaddrs.replace(existing, fresh)`](#multiaddrsreplaceexisting-fresh)\n    - [`.connect(ma)`](#connectma)\n    - [`.disconnect()`](#disconnect)\n    - [`.isConnected()`](#isconnected)\n  - [Contribute](#contribute)\n  - [License](#license)\n\n## Installation\n\n### npm\n\n```sh\n> npm i peer-info\n```\n\n### Node.JS, Browserify, Webpack\n\n```js\nconst PeerInfo = require('peer-info')\n```\n\n### Browser: `<script>` Tag\n\nLoading this module through a script tag will make the `PeerInfo` obj available in the global namespace.\n\n```html\n<script src=\"https://unpkg.com/peer-info/dist/index.min.js\"></script>\n<!-- OR -->\n<script src=\"https://unpkg.com/peer-info/dist/index.js\"></script>\n```\n\n## Usage\n\n```js\nconst PeerInfo = require('peer-info')\nconst peer = new PeerInfo()\n\n// TCP port 5001\npeer.multiaddrs.add('/ip4/1.2.3.4/tcp/5001')\n\n// UDP port 8001\npeer.multiaddrs.add('/ip4/1.2.3.4/udp/8001')\n\n// mic/speaker soundwaves using frequencies 697 and 1209\npeer.multiaddrs.add('/sonic/bfsk/697/1209')\n```\n\n## API\n\n```js\nconst PeerInfo = require('peer-info')\n```\n\n### `PeerInfo.create([id])`\n\n- `id` optional - can be a PeerId or a JSON object(will be parsed with https://github.com/libp2p/js-peer-id#createfromjsonobj)\n\nCreates a new PeerInfo instance and if no `id` is passed it\ngenerates a new underlying [PeerID](https://github.com/libp2p/js-peer-id)\nfor it.\n\nReturns `Promise<PeerInfo>`.\n\n### `new PeerInfo(id)`\n\n- `id: PeerId` - instance of PeerId (optional)\n\nCreates a new PeerInfo instance from an existing PeerId.\n\n### `.id`\n\nThe [PeerId](https://github.com/libp2p/js-peer-id) of the peer this info relates to.\n\n### `protocols`\n\nA list of protocols that `peer` supports.\n\n### `.protocols.add(protocol)`\n\nAdds a protocol that `peer` can support. `protocol` is a string.\n\n### `.protocols.delete(protocol)`\n\nRemoves a protocol that `peer` no longer supports. `protocol` is a string.\n\n### `.multiaddrs`\n\nA list of multiaddresses instances that `peer` can be reached at.\n\n### `.multiaddrs.add(addr)`\n\n- `addr: Multiaddr`\n\nAdds a new multiaddress that `peer` can be reached at. `addr` is an instance of\na [multiaddr](https://github.com/multiformats/js-multiaddr).\n\n### `.multiaddrs.addSafe(addr)`\n\n- `addr: Multiaddr`\n\nThe `addSafe` call, in comparison to `add`, will only add the multiaddr to\n`multiaddrs` if the same multiaddr tries to be added twice.\n\nThis is a simple mechanism to prevent `multiaddrs` from becoming bloated with\nunusable addresses, which happens when we exchange observed multiaddrs with\npeers which will not provide a useful multiaddr to be shared to the rest of the\nnetwork (e.g. a multiaddr referring to a peer inside a LAN being shared to the\noutside world).\n\n### `.multiaddrs.delete(addr)`\n\n- `addr: Multiaddr`\n\nRemoves a multiaddress instance `addr` from `peer`.\n\n### `.multiaddrs.replace(existing, fresh)`\n\n- `existing: Multiaddr`\n- `fresh: Multiaddr`\n\nRemoves the array of multiaddresses `existing` from `peer`, and adds the array\nof multiaddresses `fresh`.\n\n### `.connect(ma)`\n\nRecords the given multiaddr, `ma` as the active multiaddr of the peer.\n\n- `ma: Multiaddr`\n\n### `.disconnect()`\n\nRemoves the existing connected Multiaddr from tracking.\n\n### `.isConnected()`\n\nReturns `true`  if a connected Multiaddr exists, otherwise returns `false`.\n\n## Contribute\n\nPRs accepted.\n\nSmall note: If editing the Readme, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.\n\n## License\n\n[MIT © David Dias](LICENSE)\n","publish_time":1457639271657,"_cnpm_publish_time":1457639271657,"dist-tags":{"beta":"0.17.0","latest":"0.17.5"}}