Tinymath
Tinymath is a tiny arithmetic and function evaluator for simple numbers and arrays. Named properties can be accessed from an optional scope parameter and new functions can be added without rebuilding. Enjoy.
NOTE: Tinymath requires an ES6 or newer environment. You can use it with your build system of choice to run in older environments, or use the ES5 compatible version by importing tinymath/lib/tinymath.es5.js
.
See Function Documentation for details on built-in functions available in Tinymath.
// Simple math; // 30 // 3 // Named properties; // 25 // Arrays; // [21, 22, 23]; // [5, 7, 9]; // [0.4, 1, 1.8]
Adding Functions
Functions can be injected, and built in function overwritten, via the 3rd argument to evaluate
:
; // 7
Parsing
You can get to the parsed AST by importing parse
/*{ "name": "add", "args": [ 1, { "name": "random", "args": [] } ]}*/
Notes
- Floating point operations have the normal Javascript limitations