当前位置:网站首页>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
边栏推荐
- Intranet penetration series: dns2tcp of Intranet tunnel
- SAP self created table log function is enabled
- upload-labs 靶场练习
- 数据库之Mysql——概述安装篇
- Reptile learning notes, learning reptile, read this article is enough
- Learning records of some shooting ranges: sqli labs, upload labs, XSS
- 使用 Ingress 实现金丝雀发布
- 【问题解决】VS2019解决编译生成的exe文件打不开的情况
- Concours de compétences en informatique en nuage - - première partie de l'environnement cloud privé openstack
- Upload labs range practice
猜你喜欢

Redis -- why is the string length of string emstr the upper limit of 44 bytes?

Using lambda expression to solve the problem of C file name sorting (whether it is 100 or 11)

sentinel集成nacos动态更新数据原理

Go语学习笔记 - 数组 | 从零开始Go语言

Go语学习笔记 - Slice、Map | 从零开始Go语言

DVWA靶场练习

Three minutes to teach you to use Houdini fluid > > to solve particle fluid droplets

BUUCTF MISC刷题

数据库之Mysql——概述安装篇

内网渗透系列:内网隧道之icmpsh
随机推荐
BUUCTF [极客大挑战 2019]EasySQL1
Expression related to month, year and day in SVG
Reverse linked list exercise
Chapter VII asset impairment
Feign源码分析
CTF attack and defense world brush questions 51-
Construction of middleman environment mitmproxy
[programming practice / embedded competition] learning record of embedded competition (II): picture streaming based on TCP
CTF-MISC总结
yum源仓库本地搭建的两种方法
Analysis of Nacos source code
NIH降血脂指南《your guide to lowering your Cholesterol with TLC》笔记(持续更新中)
Redis事务实现乐观锁原理
SAP GUI安全性
Using lambda expression to solve the problem of C file name sorting (whether it is 100 or 11)
Positioning and decoration style
从ES、MongoDB、Redis、RocketMQ出发谈分布式存储
upload-labs 靶场练习
以下程序实现从字符串str中删除第i个字符开始的连续n个字
SAP self created table log function is enabled