This repository has been archived on 2022-11-08. You can view files and clone it, but cannot push or open issues or pull requests.
web-archived/src/utils/MergeUint8Array.ts

16 lines
330 B
TypeScript

export function MergeUint8Array(array: Uint8Array[]): Uint8Array {
let length = 0;
array.forEach((item) => {
length += item.length;
});
let mergedArray = new Uint8Array(length);
let offset = 0;
array.forEach((item) => {
mergedArray.set(item, offset);
offset += item.length;
});
return mergedArray;
}