You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
474 B
18 lines
474 B
const memory = new WebAssembly.Memory({ initial: 1 }); |
|
|
|
const log = (offset, length) => { |
|
const bytes = new Uint8Array(memory.buffer, offset, length); |
|
const string = new TextDecoder('utf8').decode(bytes); |
|
|
|
console.log(string); |
|
}; |
|
|
|
(async () => { |
|
const response = await fetch('./hello.wasm'); |
|
const bytes = await response.arrayBuffer(); |
|
const { instance } = await WebAssembly.instantiate(bytes, { |
|
env: { log, memory } |
|
}); |
|
|
|
instance.exports.hello(); |
|
})();
|
|
|