
这样 map 、filter 、reduce 这些方法也可以传递 async 函数了……
import Prray from 'prray' // 1) create const urls = Prray.from(['www.google.com', 'npmjs.org']) // 2) async method const respOnses= await urls.mapAsync(fetch) // 3) method chaining with both normal and async methods await urls .concat(['github.com', 'wikipedia.org']) .mapAsync(request) .filter(isValidHtml) .forEachAsync(saveToDB) // 4) concurrency limit const respOnses= await urls.mapAsync(fetch, { concurrency: 10 }) 工具包的文档和路径: https://github.com/Bin-Huang/prray
1 gouflv 2021 年 1 月 4 日 via iPhone 看到了 rxjs 的影子 |
2 xiaoming1992 2021 年 1 月 4 日 via Android 粗略瞄了一眼,挺有意思的 |