1.0.2 • Published 8 months ago

@celestial-cribe/calculate-string v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

calculateString_npm

It is a Javascript library for applying complex mathematical operation on string

Installation

Use the package manager npm to install.

npm install @celestial-cribe/calculate-string

Usage

import Calculator from '@celestial-cribe/calculate-string'

// instantiating the Calculator class 
let calc = new Calculator()

// passing sting in calculate function
calc.calculate("9 +   2 *    (   6 - (4 + 1) / 2) + 7")

// calculated result can be read from "result" property of class 
console.log(calc.getResult(result))
// or
console.log(calc.result)

Components

MethodsparamatersUsage
1addn: numberadd and update result property
2subtractn: numbersubtract and update result property
3multiplyn: numbermultiply and update result property
4dividen: numberdivide and update result property
5clearclear result property
6getResultreturn result property
7isGreaterPriorityo1: "+" | "-" | "" | "/" , o2: "+" | "-" | "" | "/"return true if priority of o1 is greator than o2
8operaten1: number, operation: "+" | "-" | "*" | "/", n2: numberperform provided operation on operandes n1 and n2
9calculatestr: stringcalculate the methamatical operation on string

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

1.0.2

8 months ago

1.0.1

9 months ago

1.0.0

9 months ago