Skip to content

Commit

Permalink
Fix reader issue. See Azure#28
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Kielak committed Apr 11, 2023
1 parent 3af438f commit 0f6720f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@microsoft/fetch-event-source",
"name": "@quantum-boost/fetch-event-source",
"version": "3.0.0",
"description": "A better API for making Event Source requests, with all the features of fetch()",
"homepage": "https://github.com/Azure/fetch-event-source#readme",
"repository": "github:Azure/fetch-event-source",
"bugs": {
"url": "https://github.com/Azure/fetch-event-source/issues"
"repository": {
"type": "git",
"url": "git+https://github.com/Azure/fetch-event-source.git"
},
"author": "Microsoft",
"license": "MIT",
Expand Down
8 changes: 3 additions & 5 deletions src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ export interface EventSourceMessage {
* @param onChunk A function that will be called on each new byte chunk in the stream.
* @returns {Promise<void>} A promise that will be resolved when the stream closes.
*/
export async function getBytes(stream: ReadableStream<Uint8Array>, onChunk: (arr: Uint8Array) => void) {
const reader = stream.getReader();
let result: ReadableStreamReadResult<Uint8Array>;
while (!(result = await reader.read()).done) {
onChunk(result.value);
export async function getBytes(body: any, onChunk: any) {
for await (const chunk of body) {
onChunk(chunk);
}
}

Expand Down

0 comments on commit 0f6720f

Please sign in to comment.