mirror of
https://codeberg.org/demostf/tf-demos-viewer.git
synced 2026-06-03 18:14:11 +02:00
split test
This commit is contained in:
parent
bb742bbd0a
commit
0d382e1541
5 changed files with 27 additions and 26 deletions
|
|
@ -39,10 +39,10 @@ npm test -- --safari
|
|||
|
||||
* `webpack.config.js` contains the Webpack configuration. You shouldn't need to change this, unless you have very special needs.
|
||||
|
||||
* The `js` folder contains your JavaScript code (`index.ts` is used to hook everything into Webpack, you don't need to change it).
|
||||
* The `js` folder contains your JavaScript code (`test.ts` is used to hook everything into Webpack, you don't need to change it).
|
||||
|
||||
* The `src` folder contains your Rust code.
|
||||
|
||||
* The `static` folder contains any files that you want copied as-is into the final build. It contains an `index.html` file which loads the `index.ts` file.
|
||||
* The `static` folder contains any files that you want copied as-is into the final build. It contains an `index.html` file which loads the `test.ts` file.
|
||||
|
||||
* The `tests` folder contains your Rust unit tests.
|
||||
|
|
|
|||
23
js/index.ts
23
js/index.ts
|
|
@ -1,22 +1 @@
|
|||
import {parseDemo} from "./parser";
|
||||
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
document.getElementById('file').onchange = e => {
|
||||
let file = (e.target as HTMLInputElement).files[0];
|
||||
let reader = new FileReader();
|
||||
reader.readAsArrayBuffer(file);
|
||||
|
||||
reader.onload = async function () {
|
||||
let bytes = new Uint8Array(reader.result as ArrayBuffer);
|
||||
|
||||
console.time('demo_parse');
|
||||
let parsed = await parseDemo(bytes);
|
||||
console.timeEnd('demo_parse');
|
||||
console.log(parsed.getPlayer(150, 2));
|
||||
};
|
||||
|
||||
reader.onerror = function () {
|
||||
console.log(reader.error);
|
||||
};
|
||||
};
|
||||
});
|
||||
export {parseDemo, ParsedDemo, PlayerState, WorldBoundaries, Class, Team} from "./parser";
|
||||
22
js/test.ts
Normal file
22
js/test.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import {parseDemo} from "./parser";
|
||||
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
document.getElementById('file').onchange = e => {
|
||||
let file = (e.target as HTMLInputElement).files[0];
|
||||
let reader = new FileReader();
|
||||
reader.readAsArrayBuffer(file);
|
||||
|
||||
reader.onload = async function () {
|
||||
let bytes = new Uint8Array(reader.result as ArrayBuffer);
|
||||
|
||||
console.time('demo_parse');
|
||||
let parsed = await parseDemo(bytes);
|
||||
console.timeEnd('demo_parse');
|
||||
console.log(parsed.getPlayer(150, 2));
|
||||
};
|
||||
|
||||
reader.onerror = function () {
|
||||
console.log(reader.error);
|
||||
};
|
||||
};
|
||||
});
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
<title>My Rust + Webpack project!</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src="index.js"></script>
|
||||
<script src="test.js"></script>
|
||||
<input type="file" id="file"/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ const dist = path.resolve(__dirname, "dist");
|
|||
module.exports = {
|
||||
mode: "production",
|
||||
entry: {
|
||||
index: "./js/index.ts"
|
||||
test: "./js/test.ts"
|
||||
},
|
||||
output: {
|
||||
path: dist,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue