Skip to content
This repository has been archived by the owner on Apr 9, 2021. It is now read-only.

Commit

Permalink
Drop nested Promises (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante authored and sindresorhus committed Jul 29, 2017
1 parent 21f8b5f commit bd0f22f
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ module.exports = (promise, onFinally) => {
onFinally = onFinally || (() => {});

return promise.then(
val => new Promise(resolve => {
resolve(onFinally());
}).then(() => val),
err => new Promise(resolve => {
resolve(onFinally());
}).then(() => {
val => Promise.resolve(onFinally()).then(() => val),
err => Promise.resolve(onFinally()).then(() => {
throw err;
})
);
Expand Down

0 comments on commit bd0f22f

Please sign in to comment.