summaryrefslogtreecommitdiff
path: root/cli/compilers/wasm_wrap.js
blob: c90bd55407f5bba87674d8f40429a4f1ca1f8b44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const importObject = Object.create(null);
//IMPORTS

function base64ToUint8Array(data) {
  const binString = window.atob(data);
  const size = binString.length;
  const bytes = new Uint8Array(size);
  for (let i = 0; i < size; i++) {
    bytes[i] = binString.charCodeAt(i);
  }
  return bytes;
}

const buffer = base64ToUint8Array("BASE64_DATA");
const compiled = await WebAssembly.compile(buffer);

const instance = new WebAssembly.Instance(compiled, importObject);

//EXPORTS