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

Improve readability, avoid repetition #55

Merged
merged 1 commit into from
May 2, 2018
Merged

Improve readability, avoid repetition #55

merged 1 commit into from
May 2, 2018

Conversation

fregante
Copy link
Contributor

@fregante fregante commented Feb 4, 2018

No description provided.

@sindresorhus
Copy link
Owner

What is "common usage"? What's being changed here, and why?

@fregante
Copy link
Contributor Author

fregante commented Feb 4, 2018

All are pretty minor optimizations

  • Clarity: The arguments copy is only needed to when multiArgs === true so I avoided its repetition by just grouping by multiArgs instead of errorFirst (seems logical?)
  • Clarity: no more let i = 1, results[i - 1]
  • Optimization: multiArgs === false && errorFirst === false doesn't need a wrapper, so resolve is passed verbatim as the callback
  • Optimization: multiArgs === false && errorFirst === true is probably the most common style and now it's reduced to a single if/else

@fregante fregante changed the title Optimize common usage Improve readability, avoid repetition Feb 4, 2018
@fregante
Copy link
Contributor Author

fregante commented Feb 4, 2018

Admittedly the PR title was a bit sloppy

@sindresorhus sindresorhus merged commit 6ffaeed into sindresorhus:master May 2, 2018
@sindresorhus
Copy link
Owner

Thanks. Much better!

I've further simplified the code in 523bad9 by targeting Node.js 6. Any other simplifications you can see?

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.

2 participants