MathCheck is a lightweight library for validating, simplifying, and converting mathematical expressions to LaTeX, written in TypeScript. It's perfect for educational apps, scientific tools, and financial applications that require accurate mathematical computations and formatting.
- 🚀 Lightweight and Fast: Optimized for performance in real-world applications.
- 🛠️ TypeScript First: Fully typed for better developer experience and type safety.
- 🔍 Accurate Validation: Detects syntax errors, unbalanced parentheses, and invalid characters.
- ✅ Simplification: Automatically simplifies valid mathematical expressions.
- 📄 LaTeX Conversion: Converts mathematical expressions into properly formatted LaTeX.
You can install MathCheck using npm or yarn:
npm install mathcheck
or
yarn add mathcheck
import {
validateExpression,
simplifyExpression,
convertToLatex,
} from "mathcheck";
const validation = validateExpression("(2 + 3) * 5");
console.log(validation); // { isValid: true }
const simplified = simplifyExpression("2 + 3 * 5");
console.log(simplified); // { success: true, result: 17 }
const latex = convertToLatex("(2 + 3) * 5");
console.log(latex); // { success: true, latex: '\\left(2 + 3\\right) \\cdot 5' }
validateExpression(expression: MathExpression): ValidationResult
simplifyExpression(expression: MathExpression): SimplificationResult
convertToLatex(expression: MathExpression): LatexConversionResult
- ValidationResult: { isValid: boolean, error?: string }
- SimplificationResult: { success: boolean, result?: number, error?: string }
- LatexConversionResult: { success: boolean, latex?: string, error?: string }
- Node.js version 14.0.0 or higher.
This project is licensed under the MIT License. See the LICENSE file for more information.
Feel free to open issues or submit pull requests to improve MathCheck. All contributions are welcome! 🌟
- Fork the repository.
- Create a branch for your feature: git checkout -b my-feature.
- Make your changes and commit: git commit -m 'Add my awesome feature'.
- Push to the repository: git push origin my-feature.
- Open a pull request on GitHub.
Created by Kledenai. me@kledenai.com.