Files
fil/docs/snippets/wasm/api/error_handling.md
Henrik Jess Nielsen b4c07d3693
All checks were successful
Deploy fil (kreuzberg) / deploy (push) Successful in 49s
Nomad changes
2026-06-01 23:40:55 +02:00

20 lines
595 B
Markdown

```typescript title="WASM"
import init, { extractBytes } from "kreuzberg-wasm";
await init();
const fileInput = document.getElementById("file") as HTMLInputElement;
const file = fileInput.files?.[0];
if (file) {
try {
const bytes = new Uint8Array(await file.arrayBuffer());
const result = await extractBytes(bytes, file.type || "application/pdf", undefined);
console.log(`Extracted: ${result.content.length} characters`);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.error("Extraction failed:", message);
}
}
```