nmsn
nmsn
```js Promise.resolve() .then(() => { console.log(0); return Promise.resolve(4); }) .then((res) => { console.log(res); }); Promise.resolve() .then(() => { console.log(1); }) .then(() => { console.log(2); }) .then(() => { console.log(3); })...
> 原文:https://juejin.cn/post/7067885409677606943 现在提供10个id和请求函数(请求返回promise对象),现在要求你设置一个并发数(假设为3),达到并发设置效果。 ```js async function run(){ for (let i=0;i{ console.log(`id${res}的请求已经处理完毕,当前并发为${pool.length}`); pool.splice(pool.indexOf(promise),1); }) pool.push(promise); //这里是重点,当满了就阻塞 if (pool.length==max){ await Promise.race(pool); } } } run(); ``` 这种写法存在一个问题, `Promise.race` 会将其他执行过程中的任务舍弃
 打包产物分析时出现的三种文件大小都是什么