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

Commit 74f38f4

Browse files
author
Pedro Santos
committed
chore: code review changes
1 parent 3ed1e1b commit 74f38f4

File tree

17 files changed

+77
-22
lines changed

17 files changed

+77
-22
lines changed

SPEC/BITSWAP.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* [bitswap.wantlist](#bitswapwantlist)
44
* [bitswap.stat](#bitswapstat)
55

6+
### ⚠️ Note
7+
Although not listed in the documentation, all the following APIs that actually return a **promise** can also accept a **final callback** parameter.
8+
69
### `bitswap.wantlist`
710

811
> Returns the wantlist, optionally filtered by peer ID

SPEC/BLOCK.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
* [block.rm](#blockrm)
66
* [block.stat](#blockstat)
77

8+
### ⚠️ Note
9+
Although not listed in the documentation, all the following APIs that actually return a **promise** can also accept a **final callback** parameter.
10+
811
#### `block.get`
912

1013
> Get a raw IPFS block.
@@ -75,7 +78,7 @@ const block = await ipfs.block.put(buf)
7578
console.log(block.data.toString())
7679
// Logs:
7780
// a serialized object
78-
console.log(block.cid.toBaseEncodedString())
81+
console.log(block.cid.toString())
7982
// Logs:
8083
// the CID of the object
8184

@@ -89,7 +92,7 @@ const block = await ipfs.block.put(blob, cid)
8992
console.log(block.data.toString())
9093
// Logs:
9194
// a serialized object
92-
console.log(block.cid.toBaseEncodedString())
95+
console.log(block.cid.toString())
9396
// Logs:
9497
// the CID of the object
9598
```

SPEC/BOOTSTRAP.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
* [bootstrap.list](#bootstraplist)
1111
* [bootstrap.rm](#bootstraprm)
1212

13+
### ⚠️ Note
14+
Although not listed in the documentation, all the following APIs that actually return a **promise** can also accept a **final callback** parameter.
15+
1316
#### `bootstrap.add`
1417

1518
> Add a peer address to the bootstrap list

SPEC/CONFIG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
* [config.profiles.list](#configprofileslist)
77
* [config.profiles.apply](#configprofilesapply)
88

9+
### ⚠️ Note
10+
Although not listed in the documentation, all the following APIs that actually return a **promise** can also accept a **final callback** parameter.
11+
912
#### `config.get`
1013

1114
> Returns the currently being used config. If the daemon is off, it returns the stored config.

SPEC/DAG.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ _Explore the DAG API through interactive coding challenges in our ProtoSchool tu
1010
- _[P2P data links with content addressing](https://proto.school/#/basics/) (beginner)_
1111
- _[Blogging on the Decentralized Web](https://proto.school/#/blog/) (intermediate)_
1212

13+
### ⚠️ Note
14+
Although not listed in the documentation, all the following APIs that actually return a **promise** can also accept a **final callback** parameter.
15+
1316
#### `dag.put`
1417

1518
> Store an IPLD format node
@@ -40,7 +43,7 @@ _Explore the DAG API through interactive coding challenges in our ProtoSchool tu
4043
const obj = { simple: 'object' }
4144
const cid = await ipfs.dag.put(obj, { format: 'dag-cbor', hashAlg: 'sha3-512' })
4245

43-
console.log(cid.toBaseEncodedString())
46+
console.log(cid.toString())
4447
// zBwWX9ecx5F4X54WAjmFLErnBT6ByfNxStr5ovowTL7AhaUR98RWvXPS1V3HqV1qs3r5Ec5ocv7eCdbqYQREXNUfYNuKG
4548
```
4649

@@ -85,11 +88,11 @@ const obj = {
8588
}
8689

8790
const cid = await ipfs.dag.put(obj, { format: 'dag-cbor', hashAlg: 'sha2-256' })
88-
console.log(cid.toBaseEncodedString())
91+
console.log(cid.toString())
8992
// zdpuAmtur968yprkhG9N5Zxn6MFVoqAWBbhUAkNLJs2UtkTq5
9093

91-
async function getAndLog(cid) {
92-
const result = await ipfs.dag.get(cid)
94+
async function getAndLog(cidPath) {
95+
const result = await ipfs.dag.get(cidPath)
9396
console.log(result.value)
9497
}
9598

@@ -149,7 +152,7 @@ const obj = {
149152
}
150153

151154
const cid = await ipfs.dag.put(obj, { format: 'dag-cbor', hashAlg: 'sha2-256' })
152-
console.log(cid.toBaseEncodedString())
155+
console.log(cid.toString())
153156
// zdpuAmtur968yprkhG9N5Zxn6MFVoqAWBbhUAkNLJs2UtkTq5
154157

155158
const result = await ipfs.dag.tree('zdpuAmtur968yprkhG9N5Zxn6MFVoqAWBbhUAkNLJs2UtkTq5')

SPEC/DHT.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
* [dht.put](#dhtput)
88
* [dht.query](#dhtquery)
99

10+
### ⚠️ Note
11+
Although not listed in the documentation, all the following APIs that actually return a **promise** can also accept a **final callback** parameter.
12+
1013
#### `dht.findPeer`
1114

1215
> Retrieve the Peer Info of a reachable node in the network.

SPEC/FILES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ _Explore the Mutable File System through interactive coding challenges in our [P
3838
- [files.stat](#filesstat)
3939
- [files.write](#fileswrite)
4040

41+
### ⚠️ Note
42+
Although not listed in the documentation, all the following APIs that actually return a **promise** can also accept a **final callback** parameter.
43+
4144
#### `add`
4245

4346
> Add files and data to IPFS.

SPEC/KEY.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
* [key.export](#keyexport)
88
* [key.import](#keyimport)
99

10+
### ⚠️ Note
11+
Although not listed in the documentation, all the following APIs that actually return a **promise** can also accept a **final callback** parameter.
12+
1013
#### `key.gen`
1114

1215
> Generate a new key
@@ -148,8 +151,6 @@ A great source of [examples][] can be found in the tests for this API.
148151

149152
> Export a key in a PEM encoded password protected PKCS #8
150153
151-
##### Go **NYI**
152-
153154
##### `ipfs.key.export(name, password)`
154155

155156
Where:
@@ -181,8 +182,6 @@ A great source of [examples][] can be found in the tests for this API.
181182

182183
> Import a PEM encoded password protected PKCS #8 key
183184
184-
##### Go **NYI**
185-
186185
##### `ipfs.key.import(name, pem, password)`
187186

188187
Where:

SPEC/MISCELLANEOUS.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
* [pingReadableStream](#pingreadablestream)
1010
* [resolve](#resolve)
1111

12+
### ⚠️ Note
13+
Although not listed in the documentation, all the following APIs that actually return a **promise** can also accept a **final callback** parameter.
14+
1215
#### `id`
1316

1417
> Returns the identity of the Peer
@@ -158,7 +161,7 @@ Where:
158161

159162
| Type | Description |
160163
| -------- | -------- |
161-
| `Promise<PullStream>` | A [`PullStream`][ps] of ping response objects |
164+
| `PullStream` | A [`PullStream`][ps] of ping response objects |
162165

163166
example of the returned objects:
164167

@@ -207,7 +210,7 @@ Where:
207210

208211
| Type | Description |
209212
| -------- | -------- |
210-
| `Promise<ReadableStream>` | A [`ReadableStream`][rs] of ping response objects |
213+
| `ReadableStream` | A [`ReadableStream`][rs] of ping response objects |
211214

212215
example of the returned objects:
213216

SPEC/NAME.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
* [name.pubsub.subs](#namepubsubsubs)
77
* [name.resolve](#nameresolve)
88

9+
### ⚠️ Note
10+
Although not listed in the documentation, all the following APIs that actually return a **promise** can also accept a **final callback** parameter.
11+
912
#### `name.publish`
1013

1114
> Publish an IPNS name with a given value.

SPEC/OBJECT.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
* [object.patch.appendData](#objectpatchappenddata)
1212
* [object.patch.setData](#objectpatchsetdata)
1313

14+
### ⚠️ Note
15+
Although not listed in the documentation, all the following APIs that actually return a **promise** can also accept a **final callback** parameter.
16+
1417
#### `object.new`
1518

1619
> Create a new MerkleDAG node, using a specific layout. Caveat: So far, only UnixFS object layouts are supported.
@@ -66,7 +69,7 @@ const obj = {
6669
Links: []
6770
}
6871

69-
const cid = await ipfs.object.pu(obj)
72+
const cid = await ipfs.object.put(obj)
7073
console.log(cid.toString())
7174
// Logs:
7275
// QmPb5f92FxKPYdT3QNBd1GKiL4tZUXUrzF4Hkpdr3Gf1gK
@@ -160,7 +163,7 @@ A great source of [examples][] can be found in the tests for this API.
160163

161164
| Type | Description |
162165
| -------- | -------- |
163-
| `Promise<Array>` | An Array of [DAGLink](https://github.com/vijayee/js-ipfs-merkle-dag/blob/master/src/dag-node.js#L199-L203) objects |
166+
| `Promise<Array>` | An Array of [DAGLink](https://github.com/ipld/js-ipld-dag-pb/blob/master/src/dag-link/dagLink.js) objects |
164167

165168
**Example:**
166169

SPEC/PIN.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
* [pin.ls](#pinls)
55
* [pin.rm](#pinrm)
66

7+
### ⚠️ Note
8+
Although not listed in the documentation, all the following APIs that actually return a **promise** can also accept a **final callback** parameter.
9+
710
#### `pin.add`
811

912
> Adds an IPFS object to the pinset and also stores it to the IPFS repo. pinset is the set of hashes currently pinned (not gc'able).
@@ -33,8 +36,10 @@ an array of objects is returned, each of the form:
3336
**Example:**
3437

3538
```JavaScript
36-
const pinset = await ipfs.pin.add(hash)
39+
const pinset = await ipfs.pin.add('QmWATWQ7fVPP2EFGu71UkfnqhYXDYH566qy47CnJDgvs8u')
3740
console.log(pinset)
41+
// Logs:
42+
// [ { hash: 'QmWATWQ7fVPP2EFGu71UkfnqhYXDYH566qy47CnJDgvs8u' } ]
3843
```
3944

4045
A great source of [examples][] can be found in the tests for this API.
@@ -64,6 +69,12 @@ an array of objects with keys `hash` and `type` is returned.
6469
```JavaScript
6570
const pinset = await ipfs.pin.ls()
6671
console.log(pinset)
72+
// Logs
73+
// [
74+
// { hash: Qmc5XkteJdb337s7VwFBAGtiaoj2QCEzyxtNRy3iMudc3E, type: 'recursive' },
75+
// { hash: QmZbj5ruYneZb8FuR9wnLqJCpCXMQudhSdWhdhp5U1oPWJ, type: 'indirect' },
76+
// { hash: QmSo73bmN47gBxMNqbdV6rZ4KJiqaArqJ1nu5TvFhqqj1R, type: 'indirect' }
77+
// ]
6778
```
6879

6980
A great source of [examples][] can be found in the tests for this API.

SPEC/PUBSUB.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
* [pubsub.ls](#pubsubls)
77
* [pubsub.peers](#pubsubpeers)
88

9+
### ⚠️ Note
10+
Although not listed in the documentation, all the following APIs that actually return a **promise** can also accept a **final callback** parameter.
11+
912
#### `pubsub.subscribe`
1013

1114
> Subscribe to a pubsub topic.

SPEC/REFS.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
* [refs.localReadableStream](#refslocalreadablestream)
88
* [refs.localPullStream](#refslocalpullstream)
99

10+
### ⚠️ Note
11+
Although not listed in the documentation, all the following APIs that actually return a **promise** can also accept a **final callback** parameter.
12+
1013
#### `refs`
1114

1215
> Get links (references) from an object.
@@ -72,7 +75,7 @@ for (const ref of refs) {
7275

7376
| Type | Description |
7477
| -------- | -------- |
75-
| `Promise<ReadableStream>` | A [Readable Stream][rs] representing the references |
78+
| `ReadableStream` | A [Readable Stream][rs] representing the references |
7679

7780
**Example:**
7881

@@ -99,7 +102,7 @@ stream.on('data', function (ref) {
99102

100103
| Type | Description |
101104
| -------- | -------- |
102-
| `Promise<PullStream>` | A [Pull Stream][ps] representing the references |
105+
| `PullStream` | A [Pull Stream][ps] representing the references |
103106

104107
**Example:**
105108

@@ -167,7 +170,7 @@ ipfs.refs.local(function (err, refs) {
167170

168171
| Type | Description |
169172
| -------- | -------- |
170-
| `Promise<ReadableStream>` | A [Readable Stream][rs] representing all the local references |
173+
| `ReadableStream` | A [Readable Stream][rs] representing all the local references |
171174

172175
**Example:**
173176

@@ -192,7 +195,7 @@ stream.on('data', function (ref) {
192195

193196
| Type | Description |
194197
| -------- | -------- |
195-
| `Promise<PullStream>` | A [Pull Stream][ps] representing all the local references |
198+
| `PullStream` | A [Pull Stream][ps] representing all the local references |
196199

197200
**Example:**
198201

SPEC/REPO.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
* [repo.stat](#repostat)
55
* [repo.version](#repoversion)
66

7+
### ⚠️ Note
8+
Although not listed in the documentation, all the following APIs that actually return a **promise** can also accept a **final callback** parameter.
9+
710
#### `repo.gc`
811

912
> Perform a garbage collection sweep on the repo.

SPEC/STATS.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
* [stats.bwPullStream](#statsbwpullstream)
77
* [stats.bwReadableStream](#statsbwreadablestream)
88

9+
### ⚠️ Note
10+
Although not listed in the documentation, all the following APIs that actually return a **promise** can also accept a **final callback** parameter.
11+
912
#### `stats.bitswap`
1013

1114
> Show diagnostic information on the bitswap agent.
@@ -71,7 +74,7 @@ Options are described on [`ipfs.stats.bw`](#bw).
7174

7275
| Type | Description |
7376
| -------- | -------- |
74-
| `Promise<PullStream>` | A [Pull Stream][ps] representing IPFS bandwidth information |
77+
| `PullStream` | A [Pull Stream][ps] representing IPFS bandwidth information |
7578

7679
**Example:**
7780

@@ -108,7 +111,7 @@ Options are described on [`ipfs.stats.bw`](#bw).
108111

109112
| Type | Description |
110113
| -------- | -------- |
111-
| `Promise<ReadableStream>` | A [Readable Stream][rs] representing IPFS bandwidth information |
114+
| `ReadableStream` | A [Readable Stream][rs] representing IPFS bandwidth information |
112115

113116
**Example:**
114117

SPEC/SWARM.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
* [swarm.filters.add](#swarmfiltersadd) (not implemented yet)
99
* [swarm.filters.rm](#swarmfiltersrm) (not implemented yet)
1010

11+
### ⚠️ Note
12+
Although not listed in the documentation, all the following APIs that actually return a **promise** can also accept a **final callback** parameter.
13+
1114
#### `swarm.addrs`
1215

1316
> List of known addresses of each peer connected.

0 commit comments

Comments
 (0)