knox 修订了这个 Gist . 跳至此修订
1 file changed, 11 insertions
Async-2.js(file created)
@@ -0,0 +1,11 @@ | |||
1 | + | import { mapLimit } from "async-es"; | |
2 | + | ||
3 | + | // ...or ES2017 async functions | |
4 | + | mapLimit(urls, 5, async function(url) { | |
5 | + | const response = await fetch(url) | |
6 | + | return response.body | |
7 | + | }, (err, results) => { | |
8 | + | if (err) throw err | |
9 | + | // results is now an array of the response bodies | |
10 | + | console.log(results) | |
11 | + | }) |
更新
更早