Discussion on: How to Join Arraybuffer sliced into one ArrayBuffer?

jswalker_in profile image
jswalker.in Author

It was so simple:

var array_of_arraybuffer = [ArrayBuffer(30),[ArrayBuffer(30)]; // Contain sliced ArrayBuffer

Step 1:
Loop Through : Chunk of ArrayBuffer : array_of_arraybuffer (i)

Step 2:
var merged_ab = new Uint16Array(); //In Every ith-iteration

Step 3:
Pull ith element from array of arraybuffer

var j=0,len=array_of_arraybuffer[i].length;

var tmp = new Uint8Array(merged_ab.byteLength + array_of_arraybuffer[i].byteLength);
tmp.set(new Uint8Array(merged_ab), 0);
tmp.set(new Uint8Array(array_of_arraybuffer[i]), merged_ab.byteLength);

Step 4:
/Check merged_ab.byteLength with array_of_arraybuffer[i] 's total size if it matched then it worked perfectly/