File tree 1 file changed +9
-2
lines changed
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -300,9 +300,16 @@ Packer.prototype.pack = function (value) {
300
300
}
301
301
} else if ( 'BYTES_PER_ELEMENT' in value ) {
302
302
if ( binaryFeatures . useArrayBufferView ) {
303
- this . pack_bin ( new Uint8Array ( value . buffer ) ) ;
303
+ this . pack_bin ( new Uint8Array ( value . buffer , value . byteOffset , value . byteLength ) ) ;
304
304
} else {
305
- this . pack_bin ( value . buffer ) ;
305
+ // Check if the typed array is a view over a larger ArrayBuffer
306
+ if ( value . byteOffset !== 0 || value . byteLength !== value . buffer . byteLength ) {
307
+ // If it is, copy it and use the new buffer
308
+ this . pack_bin ( new Uint8Array ( value ) . buffer ) ;
309
+ } else {
310
+ // Otherwise use the buffer directly
311
+ this . pack_bin ( value . buffer ) ;
312
+ }
306
313
}
307
314
} else if ( ( constructor == Object ) || ( constructor . toString ( ) . startsWith ( 'class' ) ) ) {
308
315
this . pack_object ( value ) ;
You can’t perform that action at this time.
0 commit comments