-
Notifications
You must be signed in to change notification settings - Fork 4
/
node.js
30 lines (26 loc) · 851 Bytes
/
node.js
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
const fs = require('fs')
const path = require('path')
const decode = require('decode')
const rawData = new Uint8Array(
fs.readFileSync(path.resolve(__dirname, 'zygote_male_w_repro.obj')),
)
const lzmaCompressedData = new Uint8Array(
fs.readFileSync(path.resolve(__dirname, 'zygote_male_w_repro.lzma')),
)
const compiled = new WebAssembly.Module(
fs.readFileSync(path.resolve(__dirname, '..', 'build', 'optimized.wasm')),
)
const memory = new WebAssembly.Memory({ initial: 10 })
const imports = {
env: {
memory,
abort: (filename, line, column) => {
throw Error(
`abort called at ${filename ? filename + ':' : ''}${line}:${column}`,
)
},
},
}
const u8Memory = new Uint8Array(memory.buffer)
const lzma = new WebAssembly.Instance(compiled, imports).exports
decode(lzma, u8Memory, lzmaCompressedData, rawData)