Skip to content
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

Collapse multiple if-statements with the same consequents #555

Merged
merged 3 commits into from Jan 22, 2020

Conversation

jridgewell
Copy link
Collaborator

I frequently write separated if-statements-with-return, even if the consequents are the same:

if (foo) {
  return null;
}

if (bar) {
  return null;
}

This is mainly to add ample comments above each if-statement. Having these join together into foo || bar ternarys should be a win if the consequents are large.

I frequently write separated if-statements-with-return, even if the consequents are the same:

```js
if (foo) {
  return null;
}

if (bar) {
  return null;
}
```

This is mainly to add ample comments above each if-statement. Having these join together into `foo || bar` ternarys should be a win if the consequents are large.
Copy link
Contributor

@L2jLiga L2jLiga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this changes! :)

@fabiosantoscode
Copy link
Collaborator

I like this, thank you!

@fabiosantoscode fabiosantoscode merged commit 9e2ff84 into terser:master Jan 22, 2020
@jridgewell jridgewell deleted the collapse-ifs branch January 22, 2020 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants