index.js 213 B

1234567891011
  1. Promise.prototype.done = function (cb) {
  2. let P = this.constructor;
  3. return this.then(
  4. (value) => P.resolve(cb()).then(() => value),
  5. (reason) =>
  6. P.resolve(cb()).then(() => {
  7. throw reason;
  8. })
  9. );
  10. };