mathd

1.0.0 • Public • Published

mathd

A small (1.78KB) parser to evaluate infix notation to values (without using eval).

Install

$ yarn add mathd

Usage

import mathd from 'mathd';
 
mathd('2 + 2');
// => 4

API

mathd(expression)

expression

  • Type: string
  • Required: ✅

An expression written in infix notation (the way math problems probably looked when you were in elementary school).

Supported operators

  • +: Addition
  • -: Subtraction
  • /: Division
  • *: Multiplication
  • ^: Exponents (alias: **)

mathd alsp supports parentheses for encapsulating expressions.

Package Sidebar

Install

npm i mathd

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

3.89 kB

Total Files

4

Last publish

Collaborators

  • renddslow