Skip to content

Commit d3fe9ba

Browse files
committed
docs: update readme signatures and @fires usage
1 parent c0aa220 commit d3fe9ba

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,46 +207,46 @@ Required keys in the `options` object:
207207

208208
> Start the libp2p Node.
209209
210-
`callback` is a function with the following `function (err) {}` signature, where `err` is an Error in case starting the node fails.
210+
`callback` following signature `function (err) {}`, where `err` is an Error in case starting the node fails.
211211

212212
#### `libp2p.stop(callback)`
213213

214214
> Stop the libp2p Node.
215215
216-
`callback` is a function with the following `function (err) {}` signature, where `err` is an Error in case stopping the node fails.
216+
`callback` following signature `function (err) {}`, where `err` is an Error in case stopping the node fails.
217217

218218
#### `libp2p.dial(peer, callback)`
219219

220220
> Dials to another peer in the network, establishes the connection.
221221
222222
- `peer`: can be an instance of [PeerInfo][], [PeerId][], [multiaddr][], or a multiaddr string
223-
- `callback` is a function with the following `function (err, conn) {}` signature, where `err` is an Error in of failure to dial the connection and `conn` is a [Connection][] instance in case of a protocol selected, if not it is undefined.
223+
- `callback` following signature `function (err, conn) {}`, where `err` is an Error in of failure to dial the connection and `conn` is a [Connection][] instance in case of a protocol selected, if not it is undefined.
224224

225225
#### `libp2p.dialProtocol(peer, protocol, callback)`
226226

227227
> Dials to another peer in the network and selects a protocol to talk with that peer.
228228
229229
- `peer`: can be an instance of [PeerInfo][], [PeerId][], [multiaddr][], or a multiaddr string
230230
- `protocol`: String that defines the protocol (e.g '/ipfs/bitswap/1.1.0')
231-
- `callback`: Function with signature `function (err, conn) {}` where `conn` is a [Connection](https://github.com/libp2p/interface-connection) object
231+
- `callback`: Function with signature `function (err, conn) {}`, where `conn` is a [Connection](https://github.com/libp2p/interface-connection) object
232232

233-
`callback` is a function with the following `function (err, conn) {}` signature, where `err` is an Error in of failure to dial the connection and `conn` is a [Connection][] instance in case of a protocol selected, if not it is undefined.
233+
`callback` following signature `function (err, conn) {}`, where `err` is an Error in of failure to dial the connection and `conn` is a [Connection][] instance in case of a protocol selected, if not it is undefined.
234234

235235
#### `libp2p.dialFSM(peer, protocol, callback)`
236236

237237
> Behaves like `.dial` and `.dialProtocol` but calls back with a Connection State Machine
238238
239239
- `peer`: can be an instance of [PeerInfo][], [PeerId][], [multiaddr][], or a multiaddr string
240240
- `protocol`: an optional String that defines the protocol (e.g '/ipfs/bitswap/1.1.0')
241-
- `callback`: Function with signature `function (err, connFSM) {}` where `connFSM` is a [Connection State Machine](https://github.com/libp2p/js-libp2p-switch#connection-state-machine)
241+
- `callback`: following signature `function (err, connFSM) {}`, where `connFSM` is a [Connection State Machine](https://github.com/libp2p/js-libp2p-switch#connection-state-machine)
242242

243243
#### `libp2p.hangUp(peer, callback)`
244244

245245
> Closes an open connection with a peer, graciously.
246246
247247
- `peer`: can be an instance of [PeerInfo][], [PeerId][] or [multiaddr][]
248248

249-
`callback` is a function with the following `function (err) {}` signature, where `err` is an Error in case stopping the node fails.
249+
`callback` following signature `function (err) {}`, where `err` is an Error in case stopping the node fails.
250250

251251
#### `libp2p.peerRouting.findPeer(id, options, callback)`
252252

@@ -272,7 +272,7 @@ Required keys in the `options` object:
272272
> Handle new protocol
273273
274274
- `protocol`: String that defines the protocol (e.g '/ipfs/bitswap/1.1.0')
275-
- `handlerFunc`: Function with signature `function (protocol, conn) {}` where `conn` is a [Connection](https://github.com/libp2p/interface-connection) object
275+
- `handlerFunc`: following signature `function (protocol, conn) {}`, where `conn` is a [Connection](https://github.com/libp2p/interface-connection) object
276276
- `matchFunc`: Function for matching on protocol (exact matching, semver, etc). Default to exact match.
277277

278278
#### `libp2p.unhandle(protocol)`
@@ -597,4 +597,4 @@ The libp2p implementation in JavaScript is a work in progress. As such, there ar
597597

598598
## License
599599

600-
[MIT](LICENSE) © David Dias
600+
[MIT](LICENSE) © Protocol Labs

src/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ const validateConfig = require('./config').validate
2626

2727
const NOT_STARTED_ERROR_MESSAGE = 'The libp2p node is not started yet'
2828

29+
/**
30+
* @fires Node#error Emitted when an error occurs
31+
* @fires Node#peer:connect Emitted when a peer is connected to this node
32+
* @fires Node#peer:disconnect Emitted when a peer disconnects from this node
33+
* @fires Node#peer:discovery Emitted when a peer is discovered
34+
* @fires Node#start Emitted when the node and its services has started
35+
* @fires Node#stop Emitted when the node and its services has stopped
36+
*/
2937
class Node extends EventEmitter {
3038
constructor (_options) {
3139
super()
@@ -159,7 +167,6 @@ class Node extends EventEmitter {
159167
* Starts the libp2p node and all sub services
160168
*
161169
* @param {function(Error)} callback
162-
* @fires Node#start
163170
* @returns {void}
164171
*/
165172
start (callback = () => {}) {
@@ -171,7 +178,6 @@ class Node extends EventEmitter {
171178
* Stop the libp2p node by closing its listeners and open connections
172179
*
173180
* @param {function(Error)} callback
174-
* @fires Node#stop
175181
* @returns {void}
176182
*/
177183
stop (callback = () => {}) {

0 commit comments

Comments
 (0)