PageSourceSearch

https://wa-lang.org/tutorial/wa-app.js

js wa-lang.org collected 2026-10-03 23:13:49 UTC 835 bytes, 42 lines download raw bytes

1(() => {
2  class WaApp {
3    constructor() {
4      this._inst = null
5    }
6
7    init(instance) {
8      this._inst = instance
9    }
10
11    async run(instance) {
12      this._inst = instance
13      this._inst.exports.main()
14    }
15
16    mem() {
17      return this._inst.exports.memory
18    }
19
20    memView(addr, len) {
21      return new DataView(this._inst.exports.memory.buffer, addr, len)
22    }
23
24    memUint8Array(addr, len) {
25      return new Uint8Array(this.Mem().buffer, addr, len)
26    }
27
28    getString(addr, len) {
29      return new TextDecoder('utf-8').decode(this.memView(addr, len))
30    }
31
32    setString(addr, len, s) {
33      const bytes = new TextEncoder('utf-8').encode(s)
34      if (len > bytes.length) {
35        len = bytes.length
36      }
37      this.memUint8Array(addr, len).set(bytes)
38    }
39  }
40
41  window.__WA_APP__ = new WaApp()
42})()

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.