1.0.9 • Published 4 years ago

@mateusznejman/mathparser-js v1.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

MathParser-JS

Simple Mathematical string parser.

Installing

npm i @mateusznejman/mathparser-js
yarn add @mateusznejman/mathparser-js

Using

import { MathBuffer } from '@mateusznejman/mathparser-js';

//Constants
//POW = ^
//SQRT = √
//PI = π

/*
Working calculations
- Add / Substract / Multiply / Divide
- Square root / Power by X
- Percents
*/
let mathString = "2+(3+8)√(2+2)*5^4^5";
let buffer = new MathBuffer(mathString);
buffer.Add('+');
buffer.Add('5');

let val = buffer.Eval();

Other Functions

import { LeftSide, RightSide, GetBracketContentLeft, GetBracketContentRight } from '@mateusznejman/mathparser-js';

const leftSide = LeftSide(text, startIndex, withBracket = false); //Get left side of sign in startIndex(to nearest sign other than 1234567890.,;'). If withBracket = true, return value contains brackets(if exists)
const rightSide = Rightide(text, startIndex, withBracket = false); //Get right side of sign in startIndex(to nearest sign other than 1234567890.,;'). If withBracket = true, return value contains brackets(if exists)
const leftBracket = GetBracketContentLeft(text, startIndex, withBracket = false); //Used when in prev char is end bracket
const rightBracket = GetBracketContentRight(text, startIndex, withBracket = false); //Used when in next char is start bracket
1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago