以下原版
Promise.prototype.finally = function (callback) {
let P = this.constructor;
return this.then(function(value) {
P.resolve(callback()).then(function(){
return value;
});
},
function (reson) {
P.resolve(callback()).then(function() {
throw reason;
});
});
};
为什么不能这样写
Promise.prototype.finally = function (callback) {
let P = this.constructor;
return this.then(function(value) {
callback();
return value;
},
function (reson) {
callback();
throw reason;
});
};
智慧大石
相关分类