Skip to content

Commit

Permalink
Add a readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Roald Storm committed Oct 19, 2022
1 parent cceb38d commit 3cfd6a8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
To get a proper handle on what this WASM thing is all about I figured I would do a little project as close to the basics as possible. I found this article https://blog.scottlogic.com/2018/04/26/webassembly-by-hand.html but since it's 4 years old there was a whole bunch of stuff that didn't work. So instead of simply following along it turned into a quite nice project.

I also made a nice interface by writing 200 lines of JS. Came out pretty fun!

To run simply do:

```bash
npm run start
```

2 changes: 1 addition & 1 deletion compile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function recompileWasm () {
const wasmModule = wabt.parseWat(inputWat, readFileSync(inputWat, "utf8"));
const { buffer } = wasmModule.toBinary({});
writeFileSync(outputWasm, buffer);
console.log("wasm recompiled and saved!");
console.log("wasm recompiled and saved!!");
}

if (fileURLToPath(import.meta.url) === process.argv[1]) {
Expand Down
2 changes: 1 addition & 1 deletion livereloader.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import livereload from "livereload";
const CWD = process.cwd()

const liveReloadConf = {"extraExts": ["mjs", "wat"], "delay": 300}
const liveReloadCallback = () => {console.log("lol")}
const liveReloadCallback = () => {console.log("reloaded")}
const liveReloadServer = livereload.createServer(liveReloadConf, liveReloadCallback);
liveReloadServer.watch(CWD);
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ <h1>Conway in action - The Game Of Life</h1>
<canvas id="canvas"/>
<script type="module" src="index.mjs"></script>
</body>
</html>
</html>
2 changes: 1 addition & 1 deletion server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ app.use(logger("dev"))
app.use(connectLivereload());
app.use(express.static(path.join(CWD, 'public')));

app.listen(port, () => console.log(`The server is listening on port ${port}`))
app.listen(port, () => console.log(`The server is listening on ${port}`))

app.get("/", (req, res) => {
res.redirect('index.html');
Expand Down

0 comments on commit 3cfd6a8

Please sign in to comment.