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

Replace indexOf with includes #1264

Merged
merged 2 commits into from
May 14, 2020

Conversation

abetomo
Copy link
Collaborator

@abetomo abetomo commented May 13, 2020

Pull Request

Problem

There was some code that was easier to understand using 'includes' than 'indexOf'.

Solution

  • Replace 'indexOf' with 'includes'
    • Changed the relevant if statement to an early return.

ChangeLog

Changed the relevant if statement to an early return.
@shadowspawn shadowspawn self-requested a review May 13, 2020 22:14
index.js Outdated
} else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
// e.g. --inspect=localhost:1234
debugOption = match[1];
if (!arg.includes('--inspect')) {
Copy link
Collaborator

@shadowspawn shadowspawn May 14, 2020

Choose a reason for hiding this comment

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

This would be better as !arg.startsWith rather than !arg.includes to match the intent of arg.indexOf === 0

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you.
I'm sure you're right

Copy link
Collaborator

@shadowspawn shadowspawn left a comment

Choose a reason for hiding this comment

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

One suggested change. Replacing the use of indexOf which require some thought for more meaningful calls is good!

Copy link
Collaborator

@shadowspawn shadowspawn left a comment

Choose a reason for hiding this comment

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

LGTM thanks

@abetomo abetomo merged commit 168ff5b into tj:develop May 14, 2020
@abetomo abetomo deleted the feature/replace_indexOf_with_includes branch May 14, 2020 08:57
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