📜  promise.allsettled polyfill 节点 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:19.029000             🧑  作者: Mango

代码示例1
Promise.allSettled = function (promises) {
  let mappedPromises = promises.map((p) => {
    return p      
      .then((value) => {        
        return {          
          status: 'fulfilled',         
          value,        
        };      
      })      
      .catch((reason) => {        
        return {          
          status: 'rejected',        
          reason,        
        };      
      });  
    });  
  return Promise.all(mappedPromises);};