mathcheck
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

npm version Build Status License Downloads

MathCheck

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.

✨ Why Use MathCheck?

  • 🚀 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.

📦 Installation

You can install MathCheck using npm or yarn:

npm install mathcheck

or

yarn add mathcheck

🛠️ Usage

Importing

import {
  validateExpression,
  simplifyExpression,
  convertToLatex,
} from "mathcheck";

Validating Mathematical Expressions

const validation = validateExpression("(2 + 3) * 5");
console.log(validation); // { isValid: true }

Simplifying Expressions

const simplified = simplifyExpression("2 + 3 * 5");
console.log(simplified); // { success: true, result: 17 }

Converting to LaTeX

const latex = convertToLatex("(2 + 3) * 5");
console.log(latex); // { success: true, latex: '\\left(2 + 3\\right) \\cdot 5' }

📜 API

validateExpression(expression: MathExpression): ValidationResult
simplifyExpression(expression: MathExpression): SimplificationResult
convertToLatex(expression: MathExpression): LatexConversionResult

Types

  • ValidationResult: { isValid: boolean, error?: string }
  • SimplificationResult: { success: boolean, result?: number, error?: string }
  • LatexConversionResult: { success: boolean, latex?: string, error?: string }

🔒 Requirements

  • Node.js version 14.0.0 or higher.

🛡️ License

This project is licensed under the MIT License. See the LICENSE file for more information.

👨‍💻 Contribution

Feel free to open issues or submit pull requests to improve MathCheck. All contributions are welcome! 🌟

  1. Fork the repository.
  2. Create a branch for your feature: git checkout -b my-feature.
  3. Make your changes and commit: git commit -m 'Add my awesome feature'.
  4. Push to the repository: git push origin my-feature.
  5. Open a pull request on GitHub.

💡 Author

Created by Kledenai. me@kledenai.com.

Package Sidebar

Install

npm i mathcheck

Weekly Downloads

13

Version

1.0.3

License

MIT

Unpacked Size

12.9 kB

Total Files

7

Last publish

Collaborators

  • kledenai