Skip to content

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 94.17%. Comparing base (8df6974) to head (c0c394e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6382   +/-   ##
=======================================
  Coverage   94.16%   94.17%           
=======================================
  Files         592      592           
  Lines       42975    42990   +15     
  Branches     6807     6807           
=======================================
+ Hits        40466    40484   +18     
+ Misses       2458     2456    -2     
+ Partials       51       50    -1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@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.

@timreichen
Copy link
Contributor

What do people think?

I like it.

@kt3k kt3k added the feat-stable feature addition to the stable API label May 4, 2025
@iuioiua
Copy link
Contributor

iuioiua commented Aug 18, 2025

I'm in favour.

@iuioiua
Copy link
Contributor

iuioiua commented Sep 9, 2025

@kt3k should we add this in?

@canac
Copy link
Contributor Author

canac commented Sep 9, 2025

I'm more than happy to rebase this if we want to move forward with it. Just let me know!

@iuioiua
Copy link
Contributor

iuioiua commented Sep 9, 2025

I suggest rebasing anyway 🙂

@canac canac force-pushed the collections-index-arg branch from bff3bbf to c0c394e Compare September 10, 2025 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
collections feat-stable feature addition to the stable API 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
4 participants