当前位置:网站首页>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
边栏推荐
- How does feign integrate hystrix
- 随笔(不定时更新)
- 云计算技能大赛 -- openstack私有云环境 第二部分
- Internal network security attack and defense: a practical guide to penetration testing (8): Authority maintenance analysis and defense
- 学fpga(从verilog到hls)
- Redis -- why is the string length of string emstr the upper limit of 44 bytes?
- CSV Column Extract列提取
- SAP GUI security
- DVWA靶场练习
- Internal network security attack and defense: a practical guide to penetration testing (IV): Authority improvement analysis and defense
猜你喜欢
![[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

Go语学习笔记 - 语言接口 | 从零开始Go语言

惨了,搞坏了领导的机密文件,吐血分享备份文件的代码技巧

Feign源码分析

内网渗透系列:内网隧道之icmptunnel(DhavalKapil师傅的)

Mysql database backup and recovery under Linux (full + incremental)

雲計算技能大賽 -- openstack私有雲環境 第一部分

利用sqlmap注入获取网址管理员账号密码

Intranet penetration series: dnscat2 of Intranet tunnel

攻防世界MISC刷题1-50
随机推荐
三星,再次“西征”
BUUCTF MISC刷題
BUUCTF [极客大挑战 2019]EasySQL1
Feign源码分析
Concours de compétences en informatique en nuage - - première partie de l'environnement cloud privé openstack
Talking about distributed storage from ES, mongodb, redis and rocketmq
Ctf-misc learning from start to give up
云计算技能大赛 -- openstack私有云环境 第二部分
Search and replacement of C text file (WinForm)
Face to face summary 2
内网渗透系列:内网隧道之icmptunnel(jamesbarlow师傅的)
yum源仓库本地搭建的两种方法
云计算赛项--2020年赛题基础部分[任务3]
Principle of sentinel integrating Nacos to update data dynamically
BUUCTF MISC刷题
Go语学习笔记 - Slice、Map | 从零开始Go语言
Construction of middleman environment mitmproxy
Export all SVG files in the specified path into pictures in PNG format (thumbnail or original size)
使用 Ingress 实现金丝雀发布
Mysql database backup and recovery under Linux (full + incremental)