File size: 324 Bytes
faca43f
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
import { sum } from "./sum";

export function concatUint8Arrays(arrays: Uint8Array[]): Uint8Array {
	const totalLength = sum(arrays.map((a) => a.length));
	const result = new Uint8Array(totalLength);
	let offset = 0;
	for (const array of arrays) {
		result.set(array, offset);
		offset += array.length;
	}
	return result;
}