JSFiddle - React, Tailwind, and code Playground
JavaScript
function concatArrayBuffers(...bufs){
const result = new Uint8Array(bufs.reduce((totalSize, buf) => totalSize + buf.byteLength, 0));
bufs.reduce((offset, buf)=>{
result.set(buf,offset)
return offset + buf.byteLength
}, 0)
return result.buffer;
}
const a = new Uint8Array(12);
const b = new Uint8Array(14);
const c = new Uint8Array(16);
const res = concatArrayBuffers(a, b, c)
console.log(res.byteLength)