blob: 3b1831ee4c0243d24f3bdad7a74a267351708079 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
require('../targets/wasm_exec.js');
var callback;
global.setCallback = (cb) => {
callback = cb;
};
global.callCallback = () => {
console.log('calling callback!');
let result = callback(1, 2, 3, 4);
console.log('result from callback:', result);
};
let go = new Go();
WebAssembly.instantiate(fs.readFileSync(process.argv[2]), go.importObject).then((result) => {
go.run(result.instance);
}).catch((err) => {
console.error(err);
process.exit(1);
});
|