From 94d3b6acdf3fc89dd20f5e22ed99e1a9a6653b41 Mon Sep 17 00:00:00 2001 From: Ze Bateira Date: Mon, 17 Feb 2020 17:54:36 +0400 Subject: [PATCH] wip: option two for using the new async iterable api --- package-lock.json | 5 +++++ package.json | 1 + src/tutorials/0005-regular-files-api/03.js | 14 ++++++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7b128508a..cf9420be4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30259,6 +30259,11 @@ "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", "dev": true }, + "it-all": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/it-all/-/it-all-1.0.1.tgz", + "integrity": "sha512-DQ8MQXVfwCktZOja1xvKdsuka7E/OJHpLKLR3tMBmg6Kfo8Kob+XRE6pRfpbkXNsGyET4lMYrQ0y5T3XXF/Akw==" + }, "javascript-stringify": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/javascript-stringify/-/javascript-stringify-1.6.0.tgz", diff --git a/package.json b/package.json index ceb277316..7ecd7135c 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "highlight.js": "^9.12.0", "ipfs": "^0.41.0", "ipfs-css": "^0.6.0", + "it-all": "^1.0.1", "meta-marked": "^0.4.2", "monaco-editor": "^0.6.1", "new-github-issue-url": "^0.2.1", diff --git a/src/tutorials/0005-regular-files-api/03.js b/src/tutorials/0005-regular-files-api/03.js index 2b6d03ad0..9c268e1c6 100644 --- a/src/tutorials/0005-regular-files-api/03.js +++ b/src/tutorials/0005-regular-files-api/03.js @@ -1,7 +1,9 @@ +import all from 'it-all' + const validate = async (result, ipfs) => { const uploadedFiles = window.uploadedFiles || false - const expectedResult = await ipfs.add(window.uploadedFiles) + const expectedResult = await all(ipfs.add(window.uploadedFiles)) if (!result) { return { @@ -47,8 +49,10 @@ const validate = async (result, ipfs) => { } const code = `/* global ipfs */ +const all = require('it-all') + const run = async (files) => { - const result = // Place your code to add a file or files here + const result = all() // Place your code to add a file or files here return result } @@ -56,15 +60,17 @@ return run ` const solution = `/* global ipfs */ +const all = require('it-all') + const run = async (files) => { - const result = await ipfs.add(files) + const result = await all(ipfs.add(files)) return result } return run ` -const modules = { cids: require('cids') } +const modules = { 'it-all': require('it-all') } const options = { overrideErrors: true