mirror of
https://github.com/denoland/deno.git
synced 2025-03-04 01:44:26 -05:00
docs(manual/wasm): add more example code. (#10250)
This commit is contained in:
parent
ffc01f9fc5
commit
a1ac17f9fa
1 changed files with 10 additions and 0 deletions
|
@ -20,3 +20,13 @@ const wasmInstance = new WebAssembly.Instance(wasmModule);
|
||||||
const main = wasmInstance.exports.main as CallableFunction
|
const main = wasmInstance.exports.main as CallableFunction
|
||||||
console.log(main().toString());
|
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());
|
||||||
|
```
|
||||||
|
|
Loading…
Add table
Reference in a new issue