Enable open-in-browser in the Game Of Life example (#69)

This commit is contained in:
Prince Mathew
2018-04-07 22:31:10 +05:30
committed by Daniel Wirtz
parent b7ef21950b
commit 89e8de5d82
4 changed files with 29 additions and 1 deletions

1
examples/game-of-life/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules/

View File

@ -6,6 +6,12 @@ An [AssemblyScript](http://assemblyscript.org) example. Continuously updates the
Instructions
------------
You have to install the 'opn' package to be able to run the `npm browser` command
```
$> npm install
```
To build [assembly/game-of-life.ts](./assembly/game-of-life.ts) to an untouched and an optimized `.wasm` including their respective `.wat` representations, run:
```

View File

@ -6,6 +6,9 @@
"build": "npm run build:untouched && npm run build:optimized",
"build:untouched": "asc assembly/game-of-life.ts -b game-of-life.untouched.wasm -t game-of-life.untouched.wat --validate --sourceMap --measure",
"build:optimized": "asc -O assembly/game-of-life.ts -b game-of-life.optimized.wasm -t game-of-life.optimized.wat --validate --sourceMap --measure",
"browser": "game-of-life.html"
"browser": "node server.js"
},
"dependencies": {
"opn": "^5.3.0"
}
}

View File

@ -0,0 +1,18 @@
var open = require('opn');
var http = require('http');
var fs = require('fs');
const PORT = 9080;
fs.readFile('./game-of-life.html', function (err, html) {
if (err) throw err;
http.createServer(function(request, response) {
response.writeHeader(200, {"Content-Type": "text/html"});
response.write(html);
response.end();
}).listen(PORT);
});
open('http://localhost:9080/game-of-life.html');