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(array): toArray - convert to empty array only for nullish #20

Merged
merged 1 commit into from Oct 31, 2022

Conversation

huynl-96
Copy link
Contributor

Description

Based on the Nullable type of the argument, it looks like we only want to convert null and undefined into empty array. But in the current logic, falsy values (such as 0, false, '', etc.) are also being converted. It is probably better to respect these values.

If there is a good reason to bypass the falsy values, please feel free to close this PR.

Linked Issues

NA

Additional context

I think we should take advantage of it.each for looping through test cases

  • input and expected (output) of test cases are grouped in the same format [input, expected]
  • Avoid code repetition for the test implementation.

I have added test cases for toArray function as the demo

@antfu
Copy link
Owner

antfu commented Oct 31, 2022

Nice catch!

@antfu antfu merged commit 4d9373e into antfu:main Oct 31, 2022
@huynl-96 huynl-96 deleted the fix/toArray branch November 1, 2022 01:08
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.

None yet

2 participants