aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata/wasmfunc.js
diff options
context:
space:
mode:
Diffstat (limited to 'testdata/wasmfunc.js')
-rw-r--r--testdata/wasmfunc.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/testdata/wasmfunc.js b/testdata/wasmfunc.js
new file mode 100644
index 000000000..3b1831ee4
--- /dev/null
+++ b/testdata/wasmfunc.js
@@ -0,0 +1,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);
+});