npm.io
1.2.1 • Published 4 years ago

fr_arithmetic_zeng

Licence
ISC
Version
1.2.1
Deps
0
Size
8 kB
Vulns
0
Weekly
0

fr_arithmetic_zeng

Can be used to calculate the four arithmetic expression of integer(+、-、*、/、(、))

Installation

With npm:

npm install fr_arithmetic_zeng

Usage

calcu(obj)

obj: { formula: string, data: {} }. formula:Hold characters expression.data:Store the value of the corresponding characters.

const fr = require('fr_arithmetic_zeng');
let result = fr.calcu({
             //公式
             formula: '(x+y)*z',
             //参数
             data: {
                 x: 1,
                 y: 2,
                 z: 1
             }
         });
console.log(result);    // 3

or

const fr = require('fr_arithmetic_zeng');
let result = fr.calcu({
             //公式
             formula: '(x+y)*z',
             //参数
             data: {
                 x: "31111111111111111111111111111111111111111111111111111111111111111111111111111111111111",
                 y: "31111111111111111111111111111111111111111111111111111111111111111111111111111111111111",
                 z: 1
             }
         });
console.log(result);    // 62222222222222222222222222222222222222222222222222222222222222222222222222222222222222

Returns a string representation of integer. obj Parameter is the object and the object needs to have attributes formula (String), data (object)