WebAssembly.Table
Create a table of function references that can be imported nito a WASM module.
Constructor
const table = new WebAssembly.Table(options);
Parameters
options
Declares information about the memory being created.
options.initial
The starting size of the memory. The size is in pages, with each page being 64Kbs in size (64 * 1024 bytes).
options.maximum Optional
The maximum number of pages the memory can grow up to. This is the total number of pages the memory can have.
options.shared Optional
Can the memory object be shared with more than one WASM module?
Example
(import "import" "memory" (memory 1 shared))
const memory = new WebAssembly.Memory({ initial: 1, shared: true });
const options = {
import: {
memory: memory
}
};
const wasm1 = await WebAssembly.instantiateStreaming(fetch('app.wasm'), options);
const wasm2 = await WebAssembly.instantiateStreaming(fetch('app.wasm'), options);
const wasm3 = await WebAssembly.instantiateStreaming(fetch('app.wasm'), options);
let uint8ArrayMemory = new Uint8Array(memory.buffer);
uint8ArrayMemory[0] = 0x01;
uint8ArrayMemory[1] = 0x02;
uint8ArrayMemory[2] = 0x03;
const m1 = wasm1.instance.exports.readMemory(0);
const m2 = wasm2.instance.exports.readMemory(1);
const m3 = wasm3.instance.exports.readMemory(2);