febs-browser
Version:
febs is a useful utilities set in browser
15 lines (14 loc) • 398 B
JavaScript
(function () {
if (typeof Promise.prototype.finally === 'function') {
return
}
Promise.prototype.finally = function (fn) {
return this
.then(function(value) {
return this.constructor.resolve(fn()).then(function() { return value })
})
.catch(function(reason) {
return this.constructor.resolve(fn()).then(function() { throw reason })
})
}
})()