Skip to content

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