当前位置:网站首页>Implementation of promise all
Implementation of promise all
2022-04-23 08:05:00 【Pen drawing Acacia】
function promiseAll(Promises)
{
return new Promise(function(resolve,reject){
if(!Array.isArray(Promises))
{
return reject(new TypeError("argument"));
}
var countNum=0;
var promiseNum=Promises.length;
var resolvedvalue=new Array(promiseNum);
for(let i=0;i<promiseNum;i++)
{
Promise.resolve(Promises[i]).then(function(value){
countNum++;
resolvedvalue[i]=value;
if(countNum===promiseNum)
{
return resolve(resolvedvalue);
}
},function(reason){
return reject(reason);
})
}
})
}
var p1=Promise.resolve(1),
p2=Promise.resolve(2),
p3=Promise.resolve(3);
promiseAll([p1,p2,p3]).then(function(value){
console.log(value)
})
版权声明
本文为[Pen drawing Acacia]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230624332640.html
边栏推荐
- MYSQL——第一章节(数据类型2)
- Intranet penetration series: pingtunnel of Intranet tunnel
- Ctf-misc summary
- How does feign integrate hystrix
- Automatically fit single line text into the target rectangle
- GUI,CLI与Unix哲学
- Jetson Xavier NX(3)Bazel Mediapipe 安装
- 从零开始完整学习机器学习和深度学习,包括理论和代码实现,主要用到scikit和MXNet,还有一些实践(kaggle上的)
- 云计算技能大赛 -- openstack私有云环境 第二部分
- 内网渗透系列:内网隧道之icmptunnel(DhavalKapil师傅的)
猜你喜欢

CSV Column Extract列提取

Internal network security attack and defense: a practical guide to penetration testing (8): Authority maintenance analysis and defense

Guoji Beisheng openstack container cloud environment construction
![[programming practice / embedded competition] learning record of embedded competition (II): picture streaming based on TCP](/img/6c/7408180d0c24560b4a68982635520e.jpg)
[programming practice / embedded competition] learning record of embedded competition (II): picture streaming based on TCP

SAP GUI安全性

随笔(不定时更新)

CTF-MISC学习之从开始到放弃
![BUUCTF [极客大挑战 2019]EasySQL1](/img/ad/afca09bc1da003393319af700e90e3.png)
BUUCTF [极客大挑战 2019]EasySQL1

Internal network security attack and defense: a practical guide to penetration testing (5): analysis and defense of horizontal movement in the domain

内网渗透系列:内网隧道之pingtunnel
随机推荐
内网渗透系列:内网隧道之icmp_tran
Analysis of Nacos source code
Reptile learning notes, learning reptile, read this article is enough
Anti shake and throttling
Asynchronous learning
Cloud computing skills competition -- Part 2 of openstack private cloud environment
Buctf MISC brossage
MySQL--锁的奥秘--数据怎么锁
CTF attack and defense world brush questions 51-
Research on system and software security (2)
Talking about distributed storage from ES, mongodb, redis and rocketmq
Ignis公链的NFT生态发展:Unicorn.art的捐赠开发之路
Chapter V investment real estate
Cloud computing skills competition -- the first part of openstack private cloud environment
GUI,CLI与Unix哲学
CTF攻防世界刷题51-
Simplify exporting to SVG data files and all images in SVG folder
Research on system and software security (I)
strcat()、strcpy()、strcmp()、strlen()
The displayed amount of ABAP ALV is inconsistent with the exported amount