Skip to content

dopey2/math-x-ts

Repository files navigation

math-x-ts

All Contributors

Math parser, AST builder for math expression & step by step solution


npm version CI PRs Welcome

📝 Documentation
🧑‍💻 Live Demo

Introduction

This library is part of an educational project. Its main goal is to give a step by step solution for any mathematical expression.

Install

npm install --save @math-x-ts/parser

or

yarn add @math-x-ts/parser

Usage

Evaluate an expression

import { evaluate } from '@math-x-ts/parser';

console.log(evaluate('4 * (1 + 2)')) // 12;

Get step by step solution

import { parse } from '@math-x-ts/parser';

const mathNode = parse('4 * (1 + 2)');
const steps = mathNode.solveAll();

console.log(steps[0].toString()); // '4 * (1 + 2)'
console.log(steps[1].toString()); // '4 * 3'
console.log(steps[2].toString()); // '12'

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Dopey2

💻 🤔

This project follows the all-contributors specification. Contributions of any kind welcome!