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

feat: add castArray and castArrayIfExists #97

Merged
merged 10 commits into from
Jul 13, 2024
Merged

feat: add castArray and castArrayIfExists #97

merged 10 commits into from
Jul 13, 2024

Conversation

aleclarson
Copy link
Member

@aleclarson aleclarson commented Jul 9, 2024

Tip

The owner of this PR can publish a preview release by commenting /publish in this PR. Afterwards, anyone can try it out by running pnpm add radashi@pr<PR_NUMBER>.

Summary

  • Both functions return a shallow copy if input is an array.
  • If input is nullish, castArray returns a (null | undefined)[] type while castArrayIfExists returns null | undefined.
  • Otherwise, both functions return T[] (e.g. string[] if input is a string).

For any code change,

  • Related documentation has been updated, if needed
  • Related tests have been added or updated, if needed
  • Related benchmarks have been added or updated, if needed

Does this PR introduce a breaking change?

No

Bundle impact

Status File Size
A src/casted/castArray.ts 77
A src/casted/castArrayIfExists.ts 87

@aleclarson
Copy link
Member Author

aleclarson commented Jul 11, 2024

I'll be renaming these to castArray and castArrayIfExists to align with Lodash.

https://lodash.com/docs/4.17.15#castArray

@aleclarson aleclarson force-pushed the main branch 2 times, most recently from 2154f96 to 6a4b4f6 Compare July 12, 2024 00:23
@aleclarson aleclarson changed the title feat: add toArray and toArrayIfExists feat: add castArray and castArrayIfExists Jul 13, 2024
@aleclarson aleclarson added the new feature This PR adds a new function or extends an existing one label Jul 13, 2024
@aleclarson aleclarson marked this pull request as ready for review July 13, 2024 21:37
@aleclarson aleclarson merged commit 8758ed7 into main Jul 13, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature This PR adds a new function or extends an existing one
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant