steinlib-ts
v0.0.1
Published
Typescript parser for SteinLib
Readme
SteinLib Typescript Parser
Inspired by Python SteinLib
A Typescript parser for the SteinLib format
Install
npm install steinlib-tsUsage
1. Define callbacks
// calbacks.ts
const callbacks = {
graph: (rawArgs: string, listArgs: string[]) => {
// ...
},
terminal: (rawArgs: string, listArgs: string[]) => {
// ...
},
coordinates: (rawArgs: string, listArgs: string[]) => {
// ...
},
// ...
};2. Setup parser
import { SteinlibParser } from "steinlib-ts";
import { callbacks } from "./callbacks";
const filePath = "path/to/file.stp";
const file = fs.readFileSync(filePath, "utf8");
const lines = file.split("\n");
const parser = new SteinlibParser(lines, callbacks);
// Will call corresponding callbacks for each parsed line
parser.parse();Examples
1. Clone the repository
git clone https://github.com/pietert2000/steinlib-ts.git2. Install dependencies
cd steinlib-ts
npm i3. Run the demo
bun examples/demo.ts