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

fix: only use arrays in results for multiples #42

Merged
merged 3 commits into from
Jan 23, 2022

Conversation

shadowspawn
Copy link
Collaborator

@shadowspawn shadowspawn commented Jan 23, 2022

In the old parse results, values[option] is always an array whether or not multiple is used. This PR makes it so an array is not used unless the option is listed in multiple, in which case values[option] is an array from the first value added.

Fixes #19

(Code previously proposed and reviewed in #26, so will look familiar logic to some.)

Side note. multiples does not make the values start with an empty array because:

  • we don't do defaults for other options
  • an empty array would make detecting whether the option has been used different for a multiple

Copy link
Collaborator

@Eomm Eomm left a comment

Choose a reason for hiding this comment

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

I did not find a test case using multiple and a single value. Do you think it is worth adding it?

Other than that LGTM

@shadowspawn
Copy link
Collaborator Author

Good suggestion, thanks @Eomm. Will do.

@bcoe bcoe merged commit c357584 into pkgjs:main Jan 23, 2022
@shadowspawn shadowspawn deleted the feature/fix-arrays branch January 23, 2022 19:15
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.

Unnecessary arrays in result values?
3 participants