This repository was archived by the owner on Mar 10, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +18
-24
lines changed Expand file tree Collapse file tree 1 file changed +18
-24
lines changed Original file line number Diff line number Diff line change 31
31
32
32
| Type | Description |
33
33
| -------- | -------- |
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:
35
37
36
- example of the returned array:
37
38
``` js
38
39
{
39
- ref: " myref " ,
40
- err: " error msg "
40
+ ref: string ,
41
+ err: Error | null
41
42
}
42
43
```
43
44
44
45
** Example:**
45
46
46
47
``` 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 })) {
50
49
if (ref .err ) {
51
50
console .error (ref .err )
52
51
} else {
@@ -66,33 +65,28 @@ for (const ref of refs) {
66
65
67
66
| Type | Description |
68
67
| -------- | -------- |
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:
70
71
71
- example of the returned array:
72
72
``` js
73
73
{
74
- ref: " myref " ,
75
- err: " error msg "
74
+ ref: string ,
75
+ err: Error | null
76
76
}
77
77
```
78
78
79
79
** Example:**
80
80
81
81
``` 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"
94
88
}
95
- })
89
+ }
96
90
```
97
91
98
92
[ examples ] : https://github.com/ipfs/interface-ipfs-core/blob/master/src/files-regular
You can’t perform that action at this time.
0 commit comments