-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove unnecessary returns in asyncToGenerator helper #5548
Conversation
@zertosh, thanks for your PR! By analyzing the history of the files in this pull request, we identified @loganfsmyth, @spicyj and @hzoo to be potential reviewers. |
Codecov Report
@@ Coverage Diff @@
## 7.0 #5548 +/- ##
=========================================
+ Coverage 85.45% 85.5% +0.05%
=========================================
Files 200 200
Lines 9506 9506
Branches 2701 2701
=========================================
+ Hits 8123 8128 +5
+ Misses 887 882 -5
Partials 496 496
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@hzoo what do I do now; can I just hit the merge button?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
I like the functions, what about this:
diff --git a/packages/babel-helpers/src/helpers.js b/packages/babel-helpers/src/helpers.js
index d7e1c0a..f081957 100644
--- a/packages/babel-helpers/src/helpers.js
+++ b/packages/babel-helpers/src/helpers.js
@@ -230,13 +230,11 @@ helpers.asyncToGenerator = template(`
if (info.done) {
resolve(value);
} else {
- Promise.resolve(value).then(function (value) {
- step("next", value);
- }, function (err) {
- step("throw", err);
- });
+ Promise.resolve(value).then(_next, _throw);
}
}
+ function _next(value) { step("next", value); }
+ function _throw(err) { step("throw", err); }
- step("next");
+ _next();
});
With mangling it could save even more bytes.
@spicyj I would wait for 2 thumbs for prs unless it's trivial - or if it's docs you can usually just merge yourself. This in particular I thought we either did this on purpose for some reason or maybe I asked about it earlier as well lol |
These
return
s aren't necessary, so remove them and save a few bytes.You can also reuse the callbacks passed to
then
- but I don't know if it's worth it: