feat(collections): stabilize index argument in iterable methods#7119
feat(collections): stabilize index argument in iterable methods#7119tomas-zijdemans wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7119 +/- ##
==========================================
+ Coverage 94.61% 94.80% +0.19%
==========================================
Files 634 618 -16
Lines 51801 51472 -329
Branches 9329 9276 -53
==========================================
- Hits 49011 48798 -213
+ Misses 2216 2122 -94
+ Partials 574 552 -22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fibibot
left a comment
There was a problem hiding this comment.
Clean stabilization. Unstable index parameter was added in #6382 (merged Jan 2026), so it's had ~4 months of in-tree usage. All 17 unstable files removed, deno.json exports cleaned up, tests rewired to the stable imports. The implementations correctly hand off the index — sortBy reuses the loop index i, the iterator paths use index++, Array.findIndex in dropWhile's array branch already takes the index natively.
- nit: JSDoc inconsistency —
sortBy,takeWhile,takeLastWhile, andfirstNotNullishOfkeep their pre-stabilization@paramtext and don't pick up the "The function receives the element and its index" wording or the "Using the index parameter"@examplethat the other 12 stabilized functions added. Worth aligning so users discover the new parameter from the docs.
|
@bartlomieju this is ready to merge |
bartlomieju
left a comment
There was a problem hiding this comment.
LGTM — matches the established stabilization pattern (cf. #6644, #7091): rename, fold tests, delete unstable variant.
One small ask before merging, not a blocker: the new @example Using the index parameter block was added to distinct_by.ts, drop_last_while.ts, drop_while.ts, and find_single.ts, but not to the other 12 stabilized functions (first_not_nullish_of, join_to_string, map_not_nullish, max_by, max_of, min_by, min_of, partition, sort_by, sum_of, take_last_while, take_while). Could you add matching examples there so the docs are consistent across the set?
This PR is a follow up to #6382
IMHO, adding the index argument should be quite natural and risk free.
I tried to keep the scope clean: Only stabilize what that PR added as unstable.