This is fork of original Promise.prototype.finally
with one small addition:
In case of rejection
finally receives error (reason) as argument.
It allows to decide which error should be passed further in promise chain.
In many cases original error is more helpful for debugging than own finally error.
Let's take an example.
Promise;// here we get the stacktrace of cleanup error, not original error that rejected the promise chain
Solution with original
Solution with modified
finally receiving error argument:
See more details in this discussion.
npm i promise.prototype.finally.err
ES Proposal spec-compliant shim for Promise.prototype.finally. Invoke its "shim" method to shim
Promise.prototype.finally if it is unavailable or noncompliant. Note: a global
Promise must already exist: the es6-shim is recommended.
Most common usage:
var assert = ;var promiseFinally = ;var resolved = Promise;var rejected = Promise;;;;promiseFinally; // will be a no-op if not neededresolved;rejected;rejected;
Simply clone the repo,
npm install, and run