-
-
Save juukie/eabb7a6db9af908238f2b6f3359f53b6 to your computer and use it in GitHub Desktop.
Polyfill to add a finally() method to the Promise object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Promise.prototype.finally = function (callback) { | |
return this.then( | |
value => this.constructor.resolve(callback()).then(() => value), | |
reason => this.constructor.resolve(callback()).then(() => { throw reason }) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment