We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
const fs = require('fs'); const uvwasi = require('uvwasi'); const { WASI } = require('wasi'); async function main() { const module = await WebAssembly.compile(fs.readFileSync('./file.wasm')); const wasi = new WASI({ preopens: { '/sandbox': './sandbox' }, args: [ './file.wasm' ] }); const importObject = { uvwasi_snapshot_preview1: uvwasi.snapshot_preview1 }; const instance = await WebAssembly.instantiate(module, { ...importObject, wasi_snapshot_preview1: wasi.wasiImport }); wasi.start(instance); const { read_file } = instance.exports; const buffer = new Uint8Array(256); const bytesRead = read_file(3, buffer.byteOffset, buffer.byteLength, 0); const text = new TextDecoder().decode(buffer.slice(0, bytesRead)); console.log(text); } main().catch((err) => { console.error(err); });
The text was updated successfully, but these errors were encountered:
// file.wat (module (import "uvwasi_snapshot_preview1" "fd_read" (func $fd_read (param i32 i32 i32 i32) (result i32))) (memory 1) (data (i32.const 0) "Hello, world!") (export "read_file" (func $read_file)) )
Sorry, something went wrong.
No branches or pull requests
The text was updated successfully, but these errors were encountered: