1/*
2 This code comes from Vincent Lab
3 And it has a video version linked here: https://www.youtube.com/watch?v=ETrbk6khfwE
4*/
5
6// Import dependencies
7import { AsBind } from "as-bind";
8import fs from "fs";
9
10(async () => {
11 // Load in the wasm file
12 const wasm = fs.readFileSync("./main.wasm");
13
14 // Instantiate the wasm file, and pass in our importObject
15 const instance = await AsBind.instantiate(wasm, {
16 utils: {
17 log(message) {
18 console.log(message);
19 }
20 }
21 });
22
23 // Run main
24 instance.exports.printName("Bob",10);
25})();