Skip to content

feat(collections/unstable): have zip accept Iterable#7120

Open
tomas-zijdemans wants to merge 2 commits into
denoland:mainfrom
tomas-zijdemans:align-zip-with-interleave
Open

feat(collections/unstable): have zip accept Iterable#7120
tomas-zijdemans wants to merge 2 commits into
denoland:mainfrom
tomas-zijdemans:align-zip-with-interleave

Conversation

@tomas-zijdemans
Copy link
Copy Markdown
Contributor

  • Mirrors the iterable-based interleave API so zip can accept any Iterable, not just arrays.
  • Non-array iterables are consumed eagerly via Array.from, then the existing index-based zip-to-shortest logic runs.
  • Adds a two-iterable fast path matching interleave.

Mirrors the iterable-based `interleave` API so `zip` can accept any
`Iterable`, not just arrays. Non-array iterables are consumed eagerly
via `Array.from`, then the existing index-based zip-to-shortest logic
runs. Adds a two-iterable fast path matching `interleave`. Lives
alongside stable `zip` to bake before any decision about replacing the
stable version.

Made-with: Cursor
@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.61%. Comparing base (a496da2) to head (e80670e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7120   +/-   ##
=======================================
  Coverage   94.61%   94.61%           
=======================================
  Files         634      635    +1     
  Lines       51801    51829   +28     
  Branches     9329     9338    +9     
=======================================
+ Hits        49011    49038   +27     
  Misses       2216     2216           
- Partials      574      575    +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.

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.

Iterable signature mirrors unstable_interleave, which is the right consistency target. Array.from(it) only runs for non-arrays — actual arrays are passed through, so the no-mutation invariant the stable zip had is preserved (the existing "handles no mutation" test still passes on a generator-free path). Two-iterable fast path matches interleave. CI is green.

  • nit: the test file is ~95% a copy of zip_test.ts — fine for now, but if zip ever gets a behaviour fix the duplication will bite. A _zip_shared_test.ts helper would dedupe.
  • nit: no test that calls zip with a single non-array iterable (e.g. zip(new Set([1,2,3]))); the multi-iterable Set/generator cases are covered.

@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