Created
July 29, 2016 07:34
-
-
Save spiralx/58675999ca5b28453538d30859761947 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