- Notifications
You must be signed in to change notification settings - Fork 258
/
Copy pathcompile-streaming.html
37 lines (29 loc) · 824 Bytes
/
compile-streaming.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!doctype html>
<html>
<head>
<metacharset="utf-8">
<title>WASM compileStreaming() test</title>
</head>
<body>
<script>
constimportObject={
my_namespace: {
imported_func: arg=>{
console.log(arg);
}
}
};
// equivalent:
// fetch("simple.wasm")
// .then(response => response.arrayBuffer())
// .then(bytes => WebAssembly.compile(bytes))
// .then(module => WebAssembly.instantiate(module, importObject))
// .then(instance => { instance.exports.exported_func(); });
WebAssembly.compileStreaming(fetch("simple.wasm"))
.then(module=>WebAssembly.instantiate(module,importObject))
.then(instance=>{
instance.exports.exported_func();
});
</script>
</body>
</html>