Files
turso/bindings/wasm/test/test.html
2025-01-01 10:31:26 -05:00

38 lines
903 B
HTML

<!DOCTYPE html>
<html>
<body>
<script type="module">
import { VFSInterface } from './src/opfs-interface.js';
console.log('made it here')
window.runTest = async () => {
console.log('made it here')
const vfs = new VFSInterface(new URL('./src/opfs-worker.js', import.meta.url).href);
console.log('made it here')
// Test file operations
const fd = await vfs.open('test.txt', {});
// Write data
const writeData = new Uint8Array([1, 2, 3, 4]);
const bytesWritten = await vfs.pwrite(fd, writeData, 0);
// Read data
const readData = new Uint8Array(4);
const bytesRead = await vfs.pread(fd, readData, 0);
// Close file
await vfs.close(fd);
return {
bytesWritten,
bytesRead,
readData: Array.from(readData)
};
};
</script>
</body>
</html>