promisu
Version:
functional promise with map filter reduce scan all race every some few try waitfor finally queue debounce throttle
14 lines (10 loc) • 315 B
JavaScript
const noop = () => {}
const PromisuFinally = (promise, onFinally) => {
const _onFinally = onFinally || noop
return promise
.then(
val => Promise.resolve(_onFinally()).then(() => val)
)
.catch(err => Promise.resolve(_onFinally()).then(() => { throw err }))
}
module.exports = PromisuFinally