美文网首页
promise.finally实现

promise.finally实现

作者: GGatsby | 来源:发表于2019-10-30 11:21 被阅读0次
Promise.prototype.finally = function (callback) {
  let P = this.constructor;
  return this.then(
    value  => P.resolve(callback()).then(() => value),
    reason => P.resolve(callback()).then(() => { throw reason })
  );
};

相关文章

网友评论

      本文标题:promise.finally实现

      本文链接:https://www.haomeiwen.com/subject/fjlovctx.html