Skip to content

Commit

Permalink
chore(async): change how we normalize thenables
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres committed Jun 27, 2016
1 parent 072a223 commit 5699c07
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions lib/async.js
Expand Up @@ -28,18 +28,14 @@
if (!isThenable(value)) {
return step(gen.next(value));
}
// Thenable might not have catch(), so we try .then() and .catch()
try {
value.then(
// Normalize thenable
Promise
.resolve(value)
.then(
result => step(gen.next(result)),
error => step(gen.throw(error))
);
if (value.catch) {
value.catch(reject);
}
} catch (err) {
reject(err);
}
)
.catch(reject);
}
});
};
Expand Down

0 comments on commit 5699c07

Please sign in to comment.