Process class implemented, not tested, all green for now, need to reevaluate the test-suite and write tests for new code and changed one

This commit is contained in:
2026-08-19 09:51:33 +02:00
parent dfa393b4d9
commit 075c999435
5 changed files with 193 additions and 27 deletions
+29
View File
@@ -0,0 +1,29 @@
import { expect, test } from "vitest";
function divideToChunks(data: Uint8Array): Uint8Array[] {
const nChunks: number = Math.ceil(data.length / 1024);
const chunks: Uint8Array[] = [];
for (let i = 0; i < nChunks; i++) {
const start = 1024 * i;
const end = 1024 * (i + 1);
chunks.push(data.slice(start, end));
}
console.log(chunks.length);
return chunks;
}
test("divide to chunks", () => {
const data: Uint8Array = new Uint8Array(2048);
const result: Uint8Array[] = divideToChunks(data);
expect(result.length).toEqual(2);
});
test("divide to chunks", () => {
const data: Uint8Array = new Uint8Array(2049);
const result = divideToChunks(data);
expect(result.length).toEqual(3);
});