feat: add Collections module
Closes https://github.com/goravel/goravel/issues/179
📑 Description
add Collections module
✅ Checks
- [ ] My pull request adheres to the code style of this project
- [ ] My code requires changes to the documentation
- [ ] I have updated the documentation as required
- [ ] All the tests have passed
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 71.34%. Comparing base (
af29523) to head (9f01f76).
Additional details and impacted files
@@ Coverage Diff @@
## master #456 +/- ##
==========================================
+ Coverage 71.25% 71.34% +0.08%
==========================================
Files 170 171 +1
Lines 10356 10388 +32
==========================================
+ Hits 7379 7411 +32
Misses 2410 2410
Partials 567 567
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
The list of methods that I want to implement (new methods will be added to this list later)
Here is the list of function names from the provided code:
- Count
- CountBy
- Each
- Filter
- GroupBy
- Keys
- Map
- Max
- Merge
- Min
- Reverse
- Shuffle
- Split
- Sum
- Unique
- Values
Could you please check this list and pick up some useful methods that can be implemented by Golang? They can be implemented in multiple PRs.
I will add the parallel methods (the callback is called as a goroutine) in another PR.
Sorry, what's the meaning of the callback is called as a goroutine?
Why are you using a 3rd party package for collection?
Sorry, what's the meaning of
the callback is called as a goroutine?
Parallel processing: like Map(), but the mapper function is called in a goroutine. Results are returned in the same order.
check this link: https://github.com/samber/lo#map
Why are you using a 3rd party package for collection?
It's ok, we don't need to implement this feature from zero.
Sorry, what's the meaning of
the callback is called as a goroutine?Parallel processing: like Map(), but the mapper function is called in a goroutine. Results are returned in the same order.
check this link: https://github.com/samber/lo#map
I see, thanks! But it may be unnecessary for now, we can implement the basic methods first.
collect is commonly known as slices in go.
@Kamandlou Please let me know if this PR can be reviewed.
@hwbrzzl I think this is enough for this PR if I want to add another method I will open another PR.
@Kamandlou Great, will take a look.
review ready @hwbrzzl :)