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

Commit 96a811e

Browse files
author
Alan Shaw
committed
docs: update refs and refs.local API docs
1 parent 018835b commit 96a811e

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

SPEC/REFS.md

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,21 @@
3131

3232
| Type | Description |
3333
| -------- | -------- |
34-
| `Promise<Array>` | An array representing the links (references) |
34+
| `AsyncIterable<Object>` | An async iterable that yields objects representing the links (references) |
35+
36+
Each yielded object is of the form:
3537

36-
example of the returned array:
3738
```js
3839
{
39-
ref: "myref",
40-
err: "error msg"
40+
ref: string,
41+
err: Error | null
4142
}
4243
```
4344

4445
**Example:**
4546

4647
```JavaScript
47-
const refs = await ipfs.refs(ipfsPath, { recursive: true })
48-
49-
for (const ref of refs) {
48+
for await (const ref of ipfs.refs(ipfsPath, { recursive: true })) {
5049
if (ref.err) {
5150
console.error(ref.err)
5251
} else {
@@ -66,33 +65,28 @@ for (const ref of refs) {
6665

6766
| Type | Description |
6867
| -------- | -------- |
69-
| `Promise<Array>` | An array representing all the local references |
68+
| `AsyncIterable<Object>` | An async iterable that yields objects representing the links (references) |
69+
70+
Each yielded object is of the form:
7071

71-
example of the returned array:
7272
```js
7373
{
74-
ref: "myref",
75-
err: "error msg"
74+
ref: string,
75+
err: Error | null
7676
}
7777
```
7878

7979
**Example:**
8080

8181
```JavaScript
82-
ipfs.refs.local(function (err, refs) {
83-
if (err) {
84-
throw err
85-
}
86-
87-
for (const ref of refs) {
88-
if (ref.err) {
89-
console.error(ref.err)
90-
} else {
91-
console.log(ref.ref)
92-
// output: "QmHash"
93-
}
82+
for await (const ref of ipfs.refs.local()) {
83+
if (ref.err) {
84+
console.error(ref.err)
85+
} else {
86+
console.log(ref.ref)
87+
// output: "QmHash"
9488
}
95-
})
89+
}
9690
```
9791

9892
[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/src/files-regular

0 commit comments

Comments
 (0)