@dev-syco/quick-math
TypeScript icon, indicating that this package has built-in type declarations

1.0.14 • Public • Published

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);
}

Package Sidebar

Install

npm i @dev-syco/quick-math

Weekly Downloads

3

Version

1.0.14

License

MIT

Unpacked Size

37.7 kB

Total Files

44

Last publish

Collaborators

  • apoloser