Uint8Arrayをマージする関数
Uint8Arrayを触っていると複数のバイナリを結合したくなるケースが出てくるので、ユーティリティ化した
function mergeU8Array(...arrays: Uint8Array[]): Uint8Array { const total = arrays.reduce((acc, cur) => acc + cur.byteLength, 0);
let offset = 0; return arrays.reduce<Uint8Array>((acc, cur) => { acc.set(cur, offset); offset += cur.byteLength; return acc; }, new Uint8Array(total));}