Skip to content
This repository has been archived by the owner on Mar 11, 2020. It is now read-only.

Commit

Permalink
chore: code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Apr 23, 2019
1 parent d062465 commit 7d6d51d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ Include this badge in your readme if you make a module that is compatible with t
```
var tape = require('tape')
var tests = require('interface-connection/tests')
var YourConnectionHandler = require('../src')
var YourConnection = require('../src')
var common = {
setup: function (transport) {
// create a pair of connections using the received transport for both endpoints
return ConnectionsPair
setup: function (c) {
return YourConnection(c)
},
teardown: function () {
// clean up any resources created by setup()
return new Promise()
}
}
Expand All @@ -72,13 +72,15 @@ A valid connection (one that follows this abstraction), must implement the follo
- `conn.getObservedAddrs()`
- `Promise<PeerInfo> conn.getPeerInfo()`
- `conn.setPeerInfo(peerInfo)`
- `conn.source()`
- `conn.sink()`
- `Promise<> conn.close()`

### Creating a connection instance

- `JavaScript` - `const conn = new Connection(connection, wrappedConnection)`

Creates a new Connection instance. `connection` is the object responsible for allowing to read or write data through the connection, while `wrappedConnection` consists on another connection that may be wrapped into the first one.
Creates a new Connection instance. `connection` is a streaming iterables duplex object responsible for allowing to read or write data through the connection, while `wrappedConnection` consists on another connection that may be wrapped into the first one.

### Get the Observed Addresses of the peer in the other end

Expand All @@ -104,6 +106,18 @@ This method stores a reference to the peerInfo Object, which contains informatio

It receives `peerInfo`, which is an object of type [Peer Info](https://github.com/libp2p/js-peer-info)

### Get a connection Source

- `JavaScript` - `conn.source()`

This getter returns the reference to the connection "source", which is an iterable object that can be consumed.

### Get a connection data collector

- `JavaScript` - `conn.sink()`

This getter returns the reference to the connection "sink", which is an iterator that consumes (or drains) a source.

### Close connection

- `JavaScript` - `conn.close()`
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
},
"homepage": "https://github.com/libp2p/interface-connection",
"dependencies": {
"err-code": "^1.1.2",
"pull-defer": "~0.2.3"
"err-code": "^1.1.2"
},
"devDependencies": {
"aegir": "^17.1.1",
Expand Down

0 comments on commit 7d6d51d

Please sign in to comment.