diff options
author | Andreu Botella <abb@randomunok.com> | 2021-07-18 00:26:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-17 18:26:11 -0400 |
commit | 03ba63e108281231a8bda851941b3dca6e29b510 (patch) | |
tree | e706516af20cfbe44e7466bbead7e27fea3e1b3e /docs/getting_started | |
parent | 240545282a87307829df1aafe74031a382d1ce33 (diff) |
docs: Document the WASM streaming APIs. (#11430)
Diffstat (limited to 'docs/getting_started')
-rw-r--r-- | docs/getting_started/webassembly.md | 13 |
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)); +``` |