diff --git a/doc/API.md b/doc/API.md index 6051362324..892ebc2b60 100644 --- a/doc/API.md +++ b/doc/API.md @@ -227,7 +227,7 @@ Dials to another peer in the network and selects a protocol to communicate with | Name | Type | Description | |------|------|-------------| | peer | [`PeerInfo`][peer-info]\|[`PeerId`][peer-id]\|[`Multiaddr`][multiaddr]\|`string` | The peer to dial. If a [`Multiaddr`][multiaddr] or its string is provided, it **must** include the peer id | -| protocols | `String|Array` | A list of protocols (or single protocol) to negotiate with. Protocols are attempted in order until a match is made. (e.g '/ipfs/bitswap/1.1.0') | +| protocols | `string|Array` | A list of protocols (or single protocol) to negotiate with. Protocols are attempted in order until a match is made. (e.g '/ipfs/bitswap/1.1.0') | | [options] | `Object` | dial options | | [options.signal] | [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) | An `AbortSignal` instance obtained from an [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) that can be used to abort the connection before it completes | @@ -286,7 +286,7 @@ In the event of a new handler for the same protocol being added, the first one i | Name | Type | Description | |------|------|-------------| -| protocols | `Array|String` | protocols to register | +| protocols | `Array|string` | protocols to register | | handler | `function({ connection:*, stream:*, protocol:string })` | handler to call | @@ -311,7 +311,7 @@ Unregisters all handlers with the given protocols | Name | Type | Description | |------|------|-------------| -| protocols | `Array|String` | protocols to unregister | +| protocols | `Array|string` | protocols to unregister | #### Example @@ -438,7 +438,7 @@ Writes a value to a key in the DHT. | Name | Type | Description | |------|------|-------------| -| key | `String` | key to add to the dht | +| key | `string` | key to add to the dht | | value | `Buffer` | value to add to the dht | | [options] | `Object` | put options | | [options.minPeers] | `number` | minimum number of peers required to successfully put (default: closestPeers.length) | @@ -469,7 +469,7 @@ Queries the DHT for a value stored for a given key. | Name | Type | Description | |------|------|-------------| -| key | `String` | key to get from the dht | +| key | `string` | key to get from the dht | | [options] | `Object` | get options | | [options.timeout] | `number` | maximum time the query should run | @@ -498,7 +498,7 @@ Queries the DHT for the n values stored for the given key (without sorting). | Name | Type | Description | |------|------|-------------| -| key | `String` | key to get from the dht | +| key | `string` | key to get from the dht | | nvals | `number` | number of values aimed | | [options] | `Object` | get options | | [options.timeout] | `number` | maximum time the query should run | @@ -528,7 +528,7 @@ Delete the provided peer from the book. | Name | Type | Description | |------|------|-------------| -| peerId | `peerid` | peerId to remove | +| peerId | [`PeerId`][peer-id] | peerId to remove | #### Returns @@ -556,7 +556,7 @@ Get the known `multiaddrInfos` of a provided peer. | Name | Type | Description | |------|------|-------------| -| peerId | `peerid` | peerId to get | +| peerId | [`PeerId`][peer-id] | peerId to get | #### Returns @@ -569,7 +569,7 @@ Get the known `multiaddrInfos` of a provided peer. ```js peerStore.addressBook.get(peerId) // undefined -peerStore.addressBook.set(peerId, discoveredMultiaddr) +peerStore.addressBook.set(peerId, multiaddr) peerStore.addressBook.get(peerId) // [ // { @@ -593,20 +593,20 @@ Get the known `multiaddr` of a provided peer. All returned multiaddrs will inclu | Name | Type | Description | |------|------|-------------| -| peerId | `peerid` | peerId to get | +| peerId | [`PeerId`][peer-id] | peerId to get | #### Returns | Type | Description | |------|-------------| -| `Array` | Array of peer's multiaddr | +| `Array` | Array of peer's multiaddr | #### Example ```js peerStore.addressBook.getMultiaddrsForPeer(peerId) // undefined -peerStore.addressBook.set(peerId, discoveredMultiaddr) +peerStore.addressBook.set(peerId, multiaddr) peerStore.addressBook.getMultiaddrsForPeer(peerId) // [ // /ip4/140.10.2.1/tcp/8000/p2p/QmW8rAgaaA6sRydK1k6vonShQME47aDxaFidbtMevWs73t @@ -624,9 +624,9 @@ Set known `multiaddrs` of a given peer. | Name | Type | Description | |------|------|-------------| -| peerId | `peerid` | peerId to set | -| multiaddrs | `multiaddr|Array` | multiaddrs to store | -| [options] | `object` | options to set | +| peerId | [`PeerId`][peer-id] | peerId to set | +| multiaddrs | `Multiaddr|Array` | multiaddrs to store | +| [options] | `Object` | options to set | | [options.replace] | `Object` | replace stored data (if exists) or unique union (default: true) | #### Returns @@ -638,7 +638,7 @@ Set known `multiaddrs` of a given peer. #### Example ```js -peerStore.addressBook.set(peerId, discoveredMultiaddr) +peerStore.addressBook.set(peerId, multiaddr) // [ // { // multiaddr: /ip4/140.10.2.1/tcp/8000, @@ -661,7 +661,7 @@ Delete the provided peer from the book. | Name | Type | Description | |------|------|-------------| -| peerId | `peerid` | peerId to remove | +| peerId | [`PeerId`][peer-id] | peerId to remove | #### Returns @@ -674,7 +674,7 @@ Delete the provided peer from the book. ```js peerStore.protoBook.delete(peerId) // false -peerStore.protoBook.set(peerId, supportedProtocols) +peerStore.protoBook.set(peerId, protocols) peerStore.protoBook.delete(peerId) // true ``` @@ -689,7 +689,7 @@ Get the known `protocols` of a provided peer. | Name | Type | Description | |------|------|-------------| -| peerId | `peerid` | peerId to get | +| peerId | [`PeerId`][peer-id] | peerId to get | #### Returns @@ -702,7 +702,7 @@ Get the known `protocols` of a provided peer. ```js peerStore.protoBook.get(peerId) // undefined -peerStore.protoBook.set(peerId, supportedProtocols) +peerStore.protoBook.set(peerId, [ '/proto/1.0.0', '/proto/1.1.0' ]) peerStore.protoBook.get(peerId) // [ '/proto/1.0.0', '/proto/1.1.0' ] ``` @@ -717,9 +717,9 @@ Set known `protocols` of a given peer. | Name | Type | Description | |------|------|-------------| -| peerId | `peerid` | peerId to set | +| peerId | [`PeerId`][peer-id] | peerId to set | | protocols | `string|Array` | protocols to store | -| [options] | `object` | options to set | +| [options] | `Object` | options to set | | [options.replace] | `Object` | replace stored data (if exists) or unique union (default: true) | #### Returns @@ -745,7 +745,7 @@ Verify if the provided peer supports the given `protocols`. | Name | Type | Description | |------|------|-------------| -| peerId | `peerid` | peerId to get | +| peerId | [`PeerId`][peer-id] | peerId to get | | protocols | `string|Array` | protocols to verify | #### Returns @@ -779,7 +779,7 @@ Delete the provided peer from every book. | Name | Type | Description | |------|------|-------------| -| peerId | `peerid` | peerId to remove | +| peerId | [`PeerId`][peer-id] | peerId to remove | #### Returns @@ -813,7 +813,7 @@ Find the stored information of a given peer. | Name | Type | Description | |------|------|-------------| -| peerId | `peerid` | peerId to find | +| peerId | [`PeerId`][peer-id] | peerId to find | #### Returns @@ -852,7 +852,7 @@ TODO: change when `peer-info` is deprecated (breaking change) #### Example ```js -for (peer of peerStore.peers().values()) { +for (let [peerIdString, peerInfo] of peerStore.peers.entries()) { // peerInfo instance } ``` @@ -873,7 +873,7 @@ Gets a list of the peer-ids that are subscribed to one topic. | Type | Description | |------|-------------| -| `Array` | peer-id subscribed to the topic | +| `Array` | peer-id subscribed to the topic | #### Example @@ -891,7 +891,7 @@ Gets a list of topics the node is subscribed to. | Type | Description | |------|-------------| -| `Array` | topics the node is subscribed to | +| `Array` | topics the node is subscribed to | #### Example @@ -938,7 +938,7 @@ Subscribes the given handler to a pubsub topic. | Name | Type | Description | |------|------|-------------| | topic | `string` | topic to subscribe | -| handler | `function({ from: String, data: Buffer, seqno: Buffer, topicIDs: Array, signature: Buffer, key: Buffer })` | handler for new data on topic | +| handler | `function({ from: string, data: Buffer, seqno: Buffer, topicIDs: Array, signature: Buffer, key: Buffer })` | handler for new data on topic | #### Returns @@ -967,7 +967,7 @@ Unsubscribes the given handler from a pubsub topic. If no handler is provided, a | Name | Type | Description | |------|------|-------------| -| topic | `string` | topic to unsubscribe | +| topic | `String` | topic to unsubscribe | | handler | `function()` | handler subscribed | #### Returns