math-exec

1.0.0 • Public • Published

math-exec.js

Evaluate math in strings safely

⚙️ Installation

npm i math-exec

CDN Links:

📖 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

Support me on PatreonCheck out my socials

Package Sidebar

Install

npm i math-exec

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

6.33 kB

Total Files

4

Last publish

Collaborators

  • axoraxdev