You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionany(arr){varP=this;returnnewP(function(resolve,reject){if(!(arr&&typeofarr.length!=='undefined')){returnreject(newTypeError('Promise.any accepts an array'));}varargs=Array.prototype.slice.call(arr);if(args.length===0)returnreject();varrejectionReasons=[];for(vari=0;i<args.length;i++){try{P.resolve(args[i]).then(resolve).catch(function(error){rejectionReasons.push(error);if(rejectionReasons.length===args.length){reject(newAggregateError(rejectionReasons,'All promises were rejected'));}});}catch(ex){reject(ex);}}});}
catch is a keyword, ie8 calling directly as a function name will result in an error
functionany(arr){varP=this;returnnewP(function(resolve,reject){if(!(arr&&typeofarr.length!=='undefined')){returnreject(newTypeError('Promise.any accepts an array'));}varargs=Array.prototype.slice.call(arr);if(args.length===0)returnreject();varrejectionReasons=[];for(vari=0;i<args.length;i++){try{P.resolve(args[i]).then(resolve)['catch'](function(error){// Modify to square brackets to call without errorrejectionReasons.push(error);if(rejectionReasons.length===args.length){reject(newAggregateError(rejectionReasons,'All promises were rejected'));}});}catch(ex){reject(ex);}}});}
The text was updated successfully, but these errors were encountered:
源码:
catch is a keyword, ie8 calling directly as a function name will result in an error
The text was updated successfully, but these errors were encountered: