-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample3.html
More file actions
57 lines (32 loc) · 795 Bytes
/
example3.html
File metadata and controls
57 lines (32 loc) · 795 Bytes
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<pre>
POT JS Example 3: Explicit Initialization
key <input id=key>
value <input id=value>
<button onclick="put()"> put </button>
<hr />
key <input id=search>
<button onclick="get()"> get </button>
value <input id=result>
</pre>
<script src="wasm_exec.js"></script>
<script>
const go = new Go()
var map;
WebAssembly.instantiateStreaming(
fetch("pot.wasm"), go.importObject)
.then((r)=>{
go.run(r.instance)
map = pot.newSwarmKvs()
})
const field = (id) => { return document.getElementById(id) }
function put() {
key = field('key').value
value = field('value').value
map.putTyped(key, value)
}
function get() {
key = field('search').value
value = map.getTyped(key)
field('result').value = value
}
</script>