这样 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-01-04 17:15:18 +08:00 via iPhone
看到了 rxjs 的影子
|
2
xiaoming1992 2021-01-04 18:24:39 +08:00 via Android
粗略瞄了一眼,挺有意思的
|