Skip to content

feat(collections): stabilize index argument in iterable methods#7119

Open
tomas-zijdemans wants to merge 3 commits into
denoland:mainfrom
tomas-zijdemans:stabilize-collections-index-arg
Open

feat(collections): stabilize index argument in iterable methods#7119
tomas-zijdemans wants to merge 3 commits into
denoland:mainfrom
tomas-zijdemans:stabilize-collections-index-arg

Conversation

@tomas-zijdemans
Copy link
Copy Markdown
Contributor

@tomas-zijdemans tomas-zijdemans commented Apr 28, 2026

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.80%. Comparing base (a496da2) to head (2e7ff9f).

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

Copy link
Copy Markdown

@fibibot fibibot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and firstNotNullishOf keep their pre-stabilization @param text and don't pick up the "The function receives the element and its index" wording or the "Using the index parameter" @example that the other 12 stabilized functions added. Worth aligning so users discover the new parameter from the docs.

@fibibot
Copy link
Copy Markdown

fibibot commented May 13, 2026

@bartlomieju this is ready to merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants