Prray
Prray 是一个支持异步操作的数组封装库,与原生数组兼容但提供更友好的异步处理方法,如 mapAsync、filterAsync 等,支持链式调用和并发控制。
• Copy the embed code to showcase this product on your website
• Share on X to spread the word about this amazing tool
很多时候,如果数组对异步函数更友好,代码写起来会更自然一些Prray -- "Promisified" Array和数组保持兼容,但对异步操作更加友好。在某些场合可以替代原生数组,让你能这么写代码:
javascriptconst urls = prray(array)const jsons = await urls.mapAsync(fetch).mapAsync(r => r.json())console.log(jsons)const files = prray(array2)await files.filterAsync(isExisted).sort(bySize).mapAsync(removeFile, { concurrency: 20 })
- 和数组保持兼容- 异步也能链状调用- 支持并发限速实现上没有任何原型链污染和全局污染,测试良好(尤其在兼容性方面),也没有其他三方依赖https://github.com/Bin-Huang/prray