simai-analyzer
v1.0.16
Published
A robust, tested and functional solution for parsing simai chart data
Readme
Functional Simai file parser for Typescript - basically sus analyzer for simai
Installation
npm i simai-analyzer[!WARNING] This project is still relatively new and is not fully done yet. Deserialisation should work fine, but serialisation is still not implemented.
Usage
Deserialize the entire maidata.txt:
import { deserializeMaidata } from "simai-analyzer/simai";
const file = `
&title=(the start of) Fragrance
&artist=Tsukasa(Arte Refact)
&wholebpm=180
&inote_5=(180.0){1},{8}3,2,1,,3,4,,6,{8}5,,7,8,,{57}2,,,,,,,E`;
const { errors, chart } = deserializeMaidata(file);
doStuffWith(chart.levels[difficulty.master].noteCollections)Deserialize a single difficulty:
import { deserializeLevel } from "simai-analyzer/simai";
const data = `(180.0){1},{8}3,2,1,,3,4,,6,{8}5,,7,8,,{57}2,,,,,,,E`;
const { errors, chart: master } = deserializeSingle(data);
doStuffWith(master.noteCollections)See the parse type UML diagram for more details on the deserialisation output.
About
Introducing a reliable and correct simai deserializer for Javascript/Typescript.
What's so good about this one?
This parser has a few good things going for it which should make the lives of developers and players easier.
- A fault tolerant system. Malformed charts still partially come through without just giving up and throwing errors.
- Entirely functional, typed and well-tested code
- Robust and clearly defined syntax parsing with Peggy.js
- A stronger emphasis on correctness over performance
- Sane API structure
- Active support
What Simai Analyzer currently is not
- Fully AstroDX compatible (but should work in 99% of use-cases)
- Fully MajData/3Simai compatible
- An absolute definitive on what simai semantics should be (but it will make clear any some assumptions where there may be ambiguities)
Building and Setup
Simai analyzer is really small and easy to set up locally.
Restore dependencies
npm installGenerate the parser
npm run genparserAt the moment, the easiest way to interact directly with the parser
is through unit tests. Simply add a test under test/ and use
npm run testto run the test suite, the existing tests should be straightforward enough to base your tests off of.
To play around with just the tokenizer, copy and paste the parser grammar into the online peggy.js parser generator. It is also possible to download the peggyjs vscode extension to test the grammar directly. Of course, unit tests are always the best way of doing tests.
Contributing
Feel free to raise issues or submit PRs in any format.
If you're going to raise an issue, describe the bug in as much detail as you can.
Try to follow the Conventional Commits style of writing commit messages.
Write code that is functional, makes ample use of the type system and includes tests. Those are all the whole point of this project.
