registerOperator, registerConstant

This commit is contained in:
Mahdi Dibaiee
2015-04-20 15:33:55 +04:30
parent 647d827e5d
commit a589a4d744
6 changed files with 61 additions and 29 deletions

View File

@ -1,28 +0,0 @@
Equation
========
Solve math expressions or create equations for repeated and complex Math tasks.
To use in browser, download [`equation.min.js`](https://raw.githubusercontent.com/mdibaiee/Equation.js/master/equation.min.js).
```javascript
// solve
console.log(Equation.solve('4 * lg(4) ^ 3')); // 32
// equation
let sphereArea = Equation.equation('4 * PI * r^2');
console.log(sphereArea(5)); // 314.1592653589793
```
API
===
####solve(expression: String)
Takes a math expression and evaluates it, returning the result.
###equation(expression: String)
Takes a math expression containing variables, returning a function which
replaces the variables with given arguments, and solves the expression.
TODO
====
* Equation solver
* More tests

View File

@ -67,6 +67,13 @@ let Equation = {
return Equation.solve(expression);
};
},
registerOperator(key, options) {
operators[key] = options;
},
registerConstant(key, options) {
constants[key] = options;
}
};