mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
docs: Document the WASM streaming APIs. (#11430)
This commit is contained in:
parent
240545282a
commit
03ba63e108
1 changed files with 12 additions and 1 deletions
|
@ -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));
|
||||
```
|
||||
|
|
Loading…
Add table
Reference in a new issue