Skip to content

Commit e25a031

Browse files
committed
Update gitapi.js
1 parent ca158f4 commit e25a031

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

git/gitapi.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,27 @@ let git = {
128128

129129
// get data from response
130130

131-
const reader = await resp.body.getReader();
131+
const reader = resp.body.getReader();
132+
let buffer = [];
132133

133-
const readerResp = await reader.read();
134-
135-
const readerChunk = readerResp.value;
136-
const readerDone = readerResp.done; // true if read all chunks
134+
async function readChunk() {
135+
136+
const chunk = await reader.read();
137+
138+
// if finished reading, return
139+
if (chunk.done) return;
140+
141+
// add new chunk to buffer
142+
buffer = new Uint8Array([...buffer, ...chunk.value]);
143+
144+
// read next chunk
145+
return readChunk();
146+
147+
}
137148

138-
return readerChunk;
149+
await readChunk();
150+
151+
return buffer;
139152

140153
},
141154

0 commit comments

Comments
 (0)