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(collections): add index arg to methods #6382

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

canac
Copy link
Contributor

@canac canac commented Feb 5, 2025

Adds an index arg to collections' predicate/selector/transformer/discriminator method. I added it only to collection helpers that operate on iterables because collection helpers that operate on records don't seem as likely to need access to the key index. Please let me know if I missed any.

Closes #6288

@canac canac requested a review from kt3k as a code owner February 5, 2025 02:14
Copy link

codecov bot commented Feb 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.23%. Comparing base (3b75ee7) to head (bff3bbf).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6382      +/-   ##
==========================================
- Coverage   96.23%   96.23%   -0.01%     
==========================================
  Files         556      556              
  Lines       42065    42075      +10     
  Branches     6371     6371              
==========================================
+ Hits        40481    40490       +9     
- Misses       1544     1545       +1     
  Partials       40       40              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kt3k kt3k added suggestion a suggestion yet to be agreed feedback welcome We want community's feedback on this issue or PR labels Feb 5, 2025
@kt3k
Copy link
Member

kt3k commented Feb 5, 2025

I'm generally in favor of the idea. It looks useful in several places, and also this is aligned to the design of builtin map methods (such as map, filter, forEach, etc)

What do people think?


Note: Currently we have policy of accepting any new feature in unstable_ prefixed path. That requires all these APIs duplicated in unstable_foo.ts, but that feels too unwieldy in this case. I'll discuss with core team about how to handle this particular case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
collections feedback welcome We want community's feedback on this issue or PR suggestion a suggestion yet to be agreed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[collections] Pass index to partition callback
2 participants