1.2.2 • Published 4 years ago

6-arithmeticer-kodomo v1.2.2

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

使用

安装依赖

npm install 6-arithmeticer-kodomo

调用

callback方式

const arith = require('6-arithmeticer-kodomo');
arith.arithmetic({
    formula: '(a+b)*c+1',
    data: {
        a: 10,
        b: 4,
        c: 3
    }
}, function (err, result) {
    if (err) {
        return console.log(err);
    }

    console.log(result); // 打印43
})

try catch方式

const arith = require('6-arithmeticer-kodomo');
try {
    const result = arith.arithmetic({
        formula: '(a+b)*c+1',
        data: {
            a: 10,
            b: 4,
            c: 3
        }
    });

    console.log(result); //打印43
} catch (err) {
    console.error(err);
}

支持TypeScript

import * as arith from '6-arithmeticer-kodomo';

const option = {
    formula: 'a+b',
    data: {
        b: 15,
        a: 10
    }
}

try {
    console.log(arith.arithmetic(option));
} catch (err: any) {
    console.error(err);
}
1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago