Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

Commit 129bf19

Browse files
authored
docs: update README to the latest changes (#169)
* docs: update links to libp2p-interfaces in README Also I see that there are 3 separate sections about contributing that duplicate each other. Should I merge them into one in this PR? * fix import in the example of README.md * update the README example to the latest API
1 parent ecbf5df commit 129bf19

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

README.md

+14-12
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
[![](https://raw.githubusercontent.com/libp2p/js-libp2p-interfaces/master/src/transport/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/src/transport)
1313
[![](https://raw.githubusercontent.com/libp2p/js-libp2p-interfaces/master/src/connection/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/src/connection)
1414

15-
> JavaScript implementation of the TCP module for libp2p. It exposes the [interface-transport](https://github.com/libp2p/js-libp2p-interfaces/tree/master/src/transport) for dial/listen. `libp2p-tcp` is a very thin shim that adds support for dialing to a `multiaddr`. This small shim will enable libp2p to use other transports.
15+
> JavaScript implementation of the TCP module for libp2p. It exposes the [interface-transport](https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/libp2p-interfaces/src/transport) for dial/listen. `libp2p-tcp` is a very thin shim that adds support for dialing to a `multiaddr`. This small shim will enable libp2p to use other transports.
1616
1717
## Table of Contents <!-- omit in toc -->
1818

@@ -39,8 +39,8 @@
3939

4040
```js
4141
import { TCP } from '@libp2p/tcp'
42-
import { Multiaddr } from '@multiformats/multiaddr'
43-
import pipe from 'it-pipe'
42+
import { multiaddr } from '@multiformats/multiaddr'
43+
import {pipe} from 'it-pipe'
4444
import all from 'it-all'
4545

4646
// A simple upgrader that just returns the MultiaddrConnection
@@ -51,12 +51,14 @@ const upgrader = {
5151

5252
const tcp = new TCP({ upgrader })
5353

54-
const listener = tcp.createListener({}, (socket) => {
55-
console.log('new connection opened')
56-
pipe(
57-
['hello'],
58-
socket
59-
)
54+
const listener = tcp.createListener({
55+
handler: (socket) => {
56+
console.log('new connection opened')
57+
pipe(
58+
['hello', ' ', 'World!'],
59+
socket
60+
)
61+
}
6062
})
6163

6264
const addr = multiaddr('/ip4/127.0.0.1/tcp/9090')
@@ -79,14 +81,14 @@ Outputs:
7981
```sh
8082
listening
8183
new connection opened
82-
Value: hello
84+
Value: hello World!
8385
```
8486

8587
## API
8688

8789
### Transport
8890

89-
[![](https://raw.githubusercontent.com/libp2p/js-libp2p-interfaces/master/src/transport/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/src/transport)
91+
[![](https://raw.githubusercontent.com/libp2p/js-libp2p-interfaces/master/packages/libp2p-interfaces/src/transport/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/libp2p-interfaces/src/transport)
9092

9193
`libp2p-tcp` accepts TCP addresses as both IPFS and non IPFS encapsulated addresses, i.e:
9294

@@ -97,7 +99,7 @@ Value: hello
9799

98100
### Connection
99101

100-
[![](https://raw.githubusercontent.com/libp2p/js-libp2p-interfaces/master/src/connection/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/src/connection)
102+
[![](https://raw.githubusercontent.com/libp2p/js-libp2p-interfaces/master/packages/libp2p-interfaces/src/connection/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/libp2p-interfaces/src/connection)
101103

102104
## Contribute
103105

0 commit comments

Comments
 (0)