summaryrefslogtreecommitdiff
path: root/docs/getting_started/webassembly.md
diff options
context:
space:
mode:
authorAndreu Botella <abb@randomunok.com>2021-07-18 00:26:11 +0200
committerGitHub <noreply@github.com>2021-07-17 18:26:11 -0400
commit03ba63e108281231a8bda851941b3dca6e29b510 (patch)
treee706516af20cfbe44e7466bbead7e27fea3e1b3e /docs/getting_started/webassembly.md
parent240545282a87307829df1aafe74031a382d1ce33 (diff)
docs: Document the WASM streaming APIs. (#11430)
Diffstat (limited to 'docs/getting_started/webassembly.md')
-rw-r--r--docs/getting_started/webassembly.md13
1 files changed, 12 insertions, 1 deletions
diff --git a/docs/getting_started/webassembly.md b/docs/getting_started/webassembly.md
index 0285c3b9a..307aba452 100644
--- a/docs/getting_started/webassembly.md
+++ b/docs/getting_started/webassembly.md
@@ -21,7 +21,7 @@ const main = wasmInstance.exports.main as CallableFunction
console.log(main().toString());
```
-And for files:
+For files:
```ts
const wasmCode = await Deno.readFile("main.wasm");
@@ -30,3 +30,14 @@ const wasmInstance = new WebAssembly.Instance(wasmModule);
const main = wasmInstance.exports.main as CallableFunction;
console.log(main().toString());
```
+
+And for loading WebAssembly modules over the network (note that the file must be
+served with `application/wasm` MIME type):
+
+```ts
+const { instance, module } = await WebAssembly.instantiateStreaming(
+ fetch("https://wpt.live/wasm/incrementer.wasm"),
+);
+const increment = instance.exports.increment as (input: number) => number;
+console.log(increment(41));
+```