Implement visualizer
This commit is contained in:
parent
11d807f289
commit
c87d537951
1
.gitignore
vendored
1
.gitignore
vendored
@ -138,3 +138,4 @@ userdata
|
||||
|
||||
# output
|
||||
output.cnf
|
||||
result.cnf
|
||||
|
@ -8,7 +8,8 @@
|
||||
"bin": "dist/bin/"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "pnpm run build && node --enable-source-maps .",
|
||||
"generate": "pnpm run build && node --enable-source-maps dist/generateRules.js",
|
||||
"visualize": "pnpm run build && node --enable-source-maps dist/visualizeResult.js",
|
||||
"test": "pnpm run build && pnpm run test:style",
|
||||
"format": "prettier --write .",
|
||||
"build": "tsc",
|
||||
@ -35,4 +36,4 @@
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.4.5"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
// Sources used: https://stackoverflow.com/a/32599033
|
||||
import { createReadStream } from "fs";
|
||||
import { createInterface } from "readline";
|
||||
import { visualizeValues } from "./src/visualizeValues";
|
||||
|
||||
async function parseInputFile(): Promise<number[]> {
|
||||
const fileStream = createReadStream("./result.cnf");
|
||||
const rl = createInterface({
|
||||
input: fileStream,
|
||||
crlfDelay: Infinity,
|
||||
});
|
||||
|
||||
const result: number[] = [];
|
||||
|
||||
for await (const line of rl) {
|
||||
if (!line.startsWith("v")) continue;
|
||||
const values = line.split(" ").slice(1).map(Number);
|
||||
|
||||
for (const value of values) {
|
||||
if (value <= 0) continue;
|
||||
result.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const values = await parseInputFile();
|
||||
console.log("Result:");
|
||||
visualizeValues(values);
|
||||
}
|
||||
|
||||
main();
|
Loading…
Reference in New Issue
Block a user