math-exec
v1.0.0
Published
Evaluate math in strings safely
Downloads
1
Readme
⚙️ Installation
npm i math-exec
CDN Links:
- https://cdn.jsdelivr.net/npm/[email protected]/math-exec.js
- https://www.unpkg.com/[email protected]/math-exec.js
📖 Usage
● Import
// ES6
import mathExec from "math-exec";
// commonjs
const mathExec = require("math-exec");
● Evaluate
mathExec("1 + 2 * 3 / 1");
mathExec("sin(45) ^ 2");
mathExec("2 + 3 % 2");
mathExec("log(10, 100) * 2");
Make sure to console.log()
the values!
| Operator names | Operator names | Operator names | | --- | --- | --- | | ** | + | - | | * | / | % | | ^ | // | log | | log10 | min | max | | random | sqrt | abs | | round | ceil | floor | | sin | cos | tan | | asin | acos | atan | | exp | floorDiv | mod | | roundTo | cbrt | expm1 | | hypot | sign | trunc |