Skip to content

Fix processInChunksByChunk to pass chunk index instead of item offset - #5

Merged
0x80 merged 1 commit into
mainfrom
thijs/1219-fix-index-logic-readme
Dec 19, 2025
Merged

0x80 merged 1 commit into
mainfrom
thijs/1219-fix-index-logic-readme

Conversation

@0x80

@0x80 0x80 commented Dec 19, 2025

Copy link
Copy Markdown
Owner

The index parameter passed to the processInChunksByChunk handler was incorrectly receiving the cumulative item offset instead of the zero-based chunk index as documented in the README.

This fix ensures the handler receives the chunk index (0, 1, 2, ...) matching the documented behavior.

The handler's index parameter was incorrectly receiving the cumulative
item offset instead of the zero-based chunk index as documented.
Copilot AI review requested due to automatic review settings December 19, 2025 15:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in processInChunksByChunk where the index parameter passed to the handler callback was incorrectly providing the cumulative item offset instead of the zero-based chunk index as documented in the README.

  • Removed the overallIndex variable that was tracking cumulative item position
  • Changed the callback to receive the chunk index directly from chunks.entries()
  • Added a test to verify chunk indices are correctly passed as 0, 1, 2, etc.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/process-in-chunks.ts Removes overallIndex tracking and passes the chunk index from chunks.entries() to the callback, fixing the mismatch between documented and actual behavior
src/process-in-chunks.test.ts Adds test case to verify that chunk indices (0, 1, 2) are correctly passed to the callback function

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@0x80
0x80 merged commit a497a5f into main Dec 19, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants