I\'d like to merge multiple arraybuffers to create a Blob. however, as you know, TypedArray dosen\'t have \"push\" or useful methods...
E.g.:
var a
if I have multiple typed arrays
arrays = [ typed_array1, typed_array2,..... typed_array100]
I want concat all 1 to 100 sub array into single 'result' this function works for me.
single_array = concat(arrays)
function concat(arrays) {
// sum of individual array lengths
let totalLength = arrays.reduce((acc, value) => acc + value.length, 0);
if (!arrays.length) return null;
let result = new Uint8Array(totalLength);
// for each array - copy it over result
// next array is copied right after the previous one
let length = 0;
for(let array of arrays) {
result.set(array, length);
length += array.length;
}
return result;
}