framework icon indicating copy to clipboard operation
framework copied to clipboard

feat: add Collections module

Open Kamandlou opened this issue 1 year ago • 9 comments

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

Kamandlou avatar Apr 11 '24 12:04 Kamandlou

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.

codecov[bot] avatar Apr 11 '24 12:04 codecov[bot]

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:

  1. Count
  2. CountBy
  3. Each
  4. Filter
  5. GroupBy
  6. Keys
  7. Map
  8. Max
  9. Merge
  10. Min
  11. Reverse
  12. Shuffle
  13. Split
  14. Sum
  15. Unique
  16. Values

Kamandlou avatar Apr 15 '24 13:04 Kamandlou

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.

hwbrzzl avatar Apr 15 '24 13:04 hwbrzzl

I will add the parallel methods (the callback is called as a goroutine) in another PR.

Kamandlou avatar Apr 16 '24 13:04 Kamandlou

Sorry, what's the meaning of the callback is called as a goroutine?

hwbrzzl avatar Apr 17 '24 01:04 hwbrzzl

Why are you using a 3rd party package for collection?

milwad-dev avatar Apr 17 '24 10:04 milwad-dev

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

Kamandlou avatar Apr 17 '24 11:04 Kamandlou

Why are you using a 3rd party package for collection?

It's ok, we don't need to implement this feature from zero.

hwbrzzl avatar Apr 18 '24 01:04 hwbrzzl

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.

hwbrzzl avatar Apr 18 '24 01:04 hwbrzzl

collect is commonly known as slices in go.

flc1125 avatar Apr 26 '24 01:04 flc1125

@Kamandlou Please let me know if this PR can be reviewed.

hwbrzzl avatar May 08 '24 03:05 hwbrzzl

@hwbrzzl I think this is enough for this PR if I want to add another method I will open another PR.

Kamandlou avatar May 09 '24 07:05 Kamandlou

@Kamandlou Great, will take a look.

hwbrzzl avatar May 10 '24 02:05 hwbrzzl

review ready @hwbrzzl :)

Kamandlou avatar May 15 '24 10:05 Kamandlou