Skip to content

Axorax/math-exec.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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