Nomad changes
All checks were successful
Deploy fil (kreuzberg) / deploy (push) Successful in 49s

This commit is contained in:
Henrik Jess Nielsen
2026-06-01 23:40:55 +02:00
parent 72b1a0a6ed
commit b4c07d3693
5723 changed files with 1130655 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import { extractBytes, initWasm } from "@kreuzberg/wasm";
async function processLargeDocumentSet(files: File[]) {
await initWasm();
const BATCH_SIZE = 5;
const results: any[] = [];
for (let i = 0; i < files.length; i += BATCH_SIZE) {
const batch = files.slice(i, i + BATCH_SIZE);
console.log(`Processing batch ${Math.floor(i / BATCH_SIZE) + 1}`);
const batchResults = await Promise.all(
batch.map(async (file) => {
const arrayBuffer = await file.arrayBuffer();
const bytes = new Uint8Array(arrayBuffer);
return extractBytes(bytes, file.type);
}),
);
results.push(...batchResults);
if (global.gc) {
console.log("Running garbage collection");
global.gc();
}
await new Promise((resolve) => setTimeout(resolve, 100));
}
return results;
}
processLargeDocumentSet([])
.then(() => console.log("Done"))
.catch(console.error);