13 lines
329 B
JavaScript
13 lines
329 B
JavaScript
import Promise from 'promise-polyfill';
|
|
|
|
Promise.prototype.finally = function finallyFn(callback) {
|
|
const constructor = this.constructor;
|
|
|
|
return this.then(
|
|
(value) => constructor.resolve(callback()).then(() => value),
|
|
(reason) => constructor.resolve(callback()).then(() => reason)
|
|
);
|
|
};
|
|
|
|
window.Promise = Promise;
|