docs: Minor fixes in Transport example readme (#199)

* docs: Fixes typos, adds instructions

* docs: adds .md bash syntax highlight
This commit is contained in:
João Santos 2018-06-04 09:56:57 +01:00 committed by David Dias
parent abc6257bf7
commit 1790ded144

View File

@ -12,7 +12,7 @@ When using libp2p, you always want to create your own libp2p Bundle, that is, pi
You will need 4 deps total, so go ahead and install all of them with:
```
```bash
> npm install libp2p libp2p-tcp peer-info async
```
@ -76,7 +76,7 @@ waterfall([
})
```
Running this should result in somehting like:
Running this should result in something like:
```bash
> node 1.js
@ -98,6 +98,12 @@ For this step, we will need one more dependency.
> npm install pull-stream
```
And we also need to import the module on our .js file:
```js
const pull = require('pull-stream')
```
We are going to reuse the MyBundle class from step 1, but this time to make things simpler, we will create two functions, one to create nodes and another to print the addrs to avoid duplicating code.
```JavaScript
@ -118,11 +124,18 @@ function printAddrs (node, number) {
console.log('node %s is listening on:', number)
node.peerInfo.multiaddrs.forEach((ma) => console.log(ma.toString()))
}
```
Now we are going to use `async/parallel` to create two nodes, print their addresses and dial from one node to the other.
```
Now we are going to use `async/parallel` to create two nodes, print their addresses and dial from one node to the other. We already added `async` as a dependency, but still need to import `async/parallel`:
```js
const parallel = require('async/parallel')
```
Then,
```js
parallel([
(cb) => createNode(cb),
(cb) => createNode(cb)
@ -172,7 +185,7 @@ What we are going to do in this step is to create 3 nodes, one with TCP, another
In this example, we will need to also install `libp2p-websockets`, go ahead and install:
```sh
```bash
> npm install libp2p-websockets
```