(module
(memory $memory 1)
(export "memory" (memory $memory))
(func (export "load_first_item_in_mem") (param $num i32) (result i32)
i32.const 0
;; load first item in memory and return the result
i32.load
)
)
var url = "{%wasm-url%}";
await WebAssembly.instantiateStreaming(fetch(url)).then(
(result) => {
const load_first_item_in_mem = result.instance.exports.load_first_item_in_mem;
const memory = result.instance.exports.memory;
var dataView = new DataView(memory.buffer);
// store 30 at the beginning of memory
dataView.setUint32(0, 30, true);
console.log(load_first_item_in_mem(100));
}
);