- 博客(1)
- 收藏
- 关注
原创 Promise实现限制并发数
在网上看了下,总结了四种方法1、使用await进行堵塞await可以接受promise的结果从而不必写thenclass limit { constructor() { this.max = 2 this.num = 0 this.queue = [] } async add(fn) { if(this.num >= this.max){ //在Promise内部把resolve放到任务队列中,只有当resolve被调...
2021-07-31 20:27:30
2313
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人