- moved uint8array concat and split functions to their own files

- fixed an error in the cd command as a result of a previous improvement
This commit is contained in:
2026-08-30 08:38:05 +02:00
parent f1b69bb282
commit d0f8376244
7 changed files with 58 additions and 69 deletions
+26
View File
@@ -0,0 +1,26 @@
export function concatUint8Arrays(arrays: Uint8Array[]): Uint8Array {
const size = arrays.reduce((sum, arr) => sum + arr.length, 0);
const array = new Uint8Array(size);
let offset = 0;
for (const arr of arrays) {
array.set(arr, offset);
offset += arr.length;
}
return array;
}
export function splitUint8Array(data: Uint8Array, size: number): Uint8Array[] {
const nChunks: number = Math.ceil(data.length / size);
const chunks: Uint8Array[] = [];
for (let i = 0; i < nChunks; i++) {
const start = size * i;
const end = size * (i + 1);
chunks.push(data.subarray(start, end));
}
return chunks;
}