Skip to content

Commit 7eaed6a

Browse files
committed
test
1 parent ee6e6fb commit 7eaed6a

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/sparse.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,16 @@ export async function from(stream) {
4343
let buffer = new Uint8Array(0);
4444

4545
const readUntil = async (byteLength) => {
46-
while (buffer.byteLength < byteLength) {
46+
if (buffer.byteLength >= byteLength) return;
47+
const parts = [buffer];
48+
let size = buffer.byteLength;
49+
while (size < byteLength) {
4750
const { value, done } = await reader.read();
4851
if (done) throw new Error("Unexpected end of stream");
49-
buffer = concatUint8Array([buffer, value]);
52+
parts.push(value);
53+
size += value.byteLength;
5054
}
55+
buffer = concatUint8Array(parts);
5156
}
5257

5358
let header;

0 commit comments

Comments
 (0)