1.0.14 • Published 4 years ago

@dev-syco/quick-math v1.0.14

Weekly downloads
7
License
MIT
Repository
github
Last release
4 years ago

Quick-math

codecov Build Status

What is this

Implementation of shunting-yard algorithm to calculate string as mathematical expression.

How does this work?

While passing expression as infix mathematical expression QuickMath will parse it and transform into RPN. After this you can simply calculate result of RPN by calling calculate method. If your expression contains syntax errors class will throw exception.

Example

import { QuickMath } from 'quick-math';
const data = '5/2+25-3^2';

try {
  const expression = new QuickMath(data);
  console.log(expression.calculate() === QuickMath.calculate(data));
} catch (e) {
  console.error(e);
}