-
-
Notifications
You must be signed in to change notification settings - Fork 0
fix: Accept ReadableStreamDefaultReader instead of ReadableStream #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…dableStream Co-authored-by: nzakas <[email protected]>
src/index.js
Outdated
| try { | ||
| while (true) { | ||
| const { done, value } = await reader.read(); | ||
| while (true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot let's use async iteration (for await...of) instead of while(true);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Added a makeReaderIterable() helper function to enable async iteration and refactored to use for await...of (ca57ec6).
src/index.js
Outdated
| } | ||
| } | ||
| } | ||
| while (true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot let's use async iteration here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Both functions now use for await...of with the makeReaderIterable() helper (ca57ec6).
Co-authored-by: nzakas <[email protected]>
Update functions to accept ReadableStreamDefaultReader
Plan:
countRowsfunction to acceptReadableStreamDefaultReader<Uint8Array>instead ofReadableStream<Uint8Array>chunkfunction to acceptReadableStreamDefaultReader<Uint8Array>instead ofReadableStream<Uint8Array>getReader()calls andreleaseLock()calls from both functionsChanges Made:
countRows()to acceptReadableStreamDefaultReader<Uint8Array>as the first parameterchunk()to acceptReadableStreamDefaultReader<Uint8Array>as the first parameterreleaseLock()calls since the reader is no longer owned by the functionscreateStreamFromString()tocreateReaderFromString()to return a readermakeReaderIterable()helper function to enable async iteration over readersfor await...ofloops instead of manualwhile(true)withreader.read()Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.