File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 33 "description" : " a package designed to facilitate the reading and writing of binary data." ,
44 "module" : " ./dist/BinaryStream.js" ,
55 "types" : " ./dist/BinaryStream.d.ts" ,
6- "version" : " 1.1.3 " ,
6+ "version" : " 1.1.4 " ,
77 "type" : " module" ,
88 "keywords" : [
99 " binary" ,
Original file line number Diff line number Diff line change @@ -119,7 +119,16 @@ class BinaryStream {
119119 * @param offset The optional offset to write the data at.
120120 * @returns The updated BinaryStream instance.
121121 */
122- write ( buffer : Uint8Array | number [ ] , offset ?: number ) : this {
122+ write ( stream : BinaryStream , offset ?: number ) : this;
123+ write ( buffer : ArrayBuffer , offset ?: number ) : this;
124+ write ( buffer : Uint8Array | number [ ] , offset ?: number ) : this;
125+ write ( buffer : any , offset ?: number ) : this {
126+ if ( buffer instanceof ArrayBuffer ) {
127+ buffer = new Uint8Array ( buffer ) ;
128+ } else if ( buffer instanceof BinaryStream ) {
129+ buffer = buffer . buffer ;
130+ }
131+
123132 const { start, end } = this . increaseOffset ( buffer . length , offset ) ;
124133 if ( end > this . length ) {
125134 this . resize ( end , false ) ;
@@ -169,6 +178,10 @@ class BinaryStream {
169178 return this . view . buffer . byteLength ;
170179 }
171180
181+ get arrayBuffer ( ) : ArrayBuffer {
182+ return this . view . buffer ;
183+ }
184+
172185 /**
173186 * Creates a Blob from the buffer.
174187 * @param type The MIME type of the Blob.
You can’t perform that action at this time.
0 commit comments