cool-admin-vue/cool/core/common/index.js
2021-02-28 01:55:04 +08:00

12 lines
213 B
JavaScript

Promise.prototype.done = function (cb) {
let P = this.constructor;
return this.then(
(value) => P.resolve(cb()).then(() => value),
(reason) =>
P.resolve(cb()).then(() => {
throw reason;
})
);
};