当前位置:网站首页>promise all的实现
promise all的实现
2022-04-23 06:25:00 【笔描相思】
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)
})
版权声明
本文为[笔描相思]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_44788119/article/details/120903188
边栏推荐
- SAP Excel 已完成文件级验证和修复。此工作簿的某些部分可能已被修复或丢弃。
- 12. Constraints
- 如何SQL 语句UNION实现当一个表中的一列内容为空时则取另一个表的另一列
- Implementation of MySQL persistence
- Super classic & Programming Guide (red and blue book) - Reading Notes
- Mysql 索引
- SAP 导出Excel文件打开显示:“xxx“的文件格式和扩展名不匹配。文件可能已损坏或不安全。除非您信任其来源,否则请勿打开。是否仍要打开它?
- npm 安装踩坑
- 对js中argumens的简单理解
- Redis connection error err auth < password > called without any password configured for the default user
猜你喜欢

数据分析入门 | kaggle泰坦尼克任务(四)—>数据清洗及特征处理

Javscript gets the real suffix of the file

数论分块(整除分块)

SAP pi / PO rfc2soap publishes RFC interface as WS example

SAP PI / Po rfc2restful Publishing RFC interface as restful examples (proxy indirect)

ogldev-读书笔记

SAP DEBUG调试FOR IN、REDUCE等复杂的语句

SAP SALV14 后台输出SALV数据可直接保存文件,发送Email(带排序、超链接、筛选格式)

安装配置淘宝镜像npm(cnpm)

Background management system framework, there is always what you want
随机推荐
图论入门——建图
Visualization Road (IX) detailed explanation of arrow class
每日一题 | 曾被反转链表支配的恐惧
Methods of database query optimization
5. Sql99 standard: internal connection and external connection
Reflection on the systematic design of Android audio and video caching mechanism
SAP 03-AMDP CDS Table Function using ‘WITH‘ Clause(Join子查询内容)
ABAP 7.4 SQL Window Expression
经典套路:一类字符串计数的DP问题
How to judge whether a point is within a polygon (including complex polygons or a large number of polygons)
Django使用mysql数据库报错解决
AuthorizationServer(授权服务器的简单搭建)
Mysql 索引
Hot change scheme and dynamic update strategy of mobile game
超级宝典&编程指南(红蓝宝书)-读书笔记
Learn to use search engines
对js中argumens的简单理解
Preliminary configuration of OpenGL super Dictionary (freeglut, glew, gltools, GLUT)
反思 | 事件总线的局限性,组件化开发流程中通信机制的设计与实现
1D/1D动态规划学习总结