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

Add all helper functions in the same loop #336

Merged
merged 1 commit into from
Jun 16, 2017

Conversation

lukechilds
Copy link
Contributor

@lukechilds lukechilds commented Jun 16, 2017

Just noticed the HTTP method helper functions are added to got in a forEach loop and then again to got.stream in a for in loop a few lines down. They might as well be added in the same loop.

index.js Outdated

helpers.forEach(el => {
got[el] = (url, opts) => got(url, Object.assign({}, opts, {method: el}));
].forEach(method => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Use for...of instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kevva Done 👍

Why is for of preferable over forEach?

Copy link
Owner

Choose a reason for hiding this comment

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

Personal preference, consistency, and it's faster.

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.

3 participants