Skip to content

Commit befade9

Browse files
committed
update constructor to make use of ArrayBuffer when possible
1 parent 3ce8c59 commit befade9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/BinaryStream.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ class BinaryStream {
3636
}
3737
if (buffer instanceof ArrayBuffer) {
3838
this.view = new DataView(buffer);
39+
} else if (buffer instanceof Uint8Array) {
40+
this.view = new DataView(buffer.buffer);
3941
} else {
40-
this.view = new DataView(new ArrayBuffer(0));
41-
this.write(buffer);
42+
this.view = new DataView(new Uint8Array(buffer).buffer);
4243
}
4344

4445
this.offset = offset;

0 commit comments

Comments
 (0)