1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

docs(manual/wasm): add more example code. (#10250)

This commit is contained in:
grian 2021-04-21 12:27:48 +03:00 committed by GitHub
parent ffc01f9fc5
commit a1ac17f9fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,3 +20,13 @@ const wasmInstance = new WebAssembly.Instance(wasmModule);
const main = wasmInstance.exports.main as CallableFunction
console.log(main().toString());
```
And for files:
```ts
const wasmCode = await Deno.readFile("main.wasm");
const wasmModule = new WebAssembly.Module(wasmCode);
const wasmInstance = new WebAssembly.Instance(wasmModule);
const main = wasmInstance.exports.main as CallableFunction;
console.log(main().toString());
```