Skip to content

Commit cba64d4

Browse files
committed
wip: option one for using the new async iterable api
1 parent 1d1c0b5 commit cba64d4

File tree

1 file changed

+14
-3
lines changed
  • src/tutorials/0005-regular-files-api

1 file changed

+14
-3
lines changed

src/tutorials/0005-regular-files-api/03.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
const validate = async (result, ipfs) => {
22
const uploadedFiles = window.uploadedFiles || false
3+
const expectedResult = []
34

4-
const expectedResult = await ipfs.add(window.uploadedFiles)
5+
for await (const result of ipfs.add(window.uploadedFiles)) {
6+
expectedResult.push(result)
7+
}
58

69
if (!result) {
710
return {
@@ -48,7 +51,11 @@ const validate = async (result, ipfs) => {
4851

4952
const code = `/* global ipfs */
5053
const run = async (files) => {
51-
const result = // Place your code to add a file or files here
54+
const result = []
55+
56+
for await (const resultPart of ) {
57+
// Place your code to add a file or files here and on the for await of loop
58+
}
5259
5360
return result
5461
}
@@ -57,7 +64,11 @@ return run
5764

5865
const solution = `/* global ipfs */
5966
const run = async (files) => {
60-
const result = await ipfs.add(files)
67+
const result = []
68+
69+
for await (const resultPart of ipfs.add(files)) {
70+
result.push(resultPart)
71+
}
6172
6273
return result
6374
}

0 commit comments

Comments
 (0)