Update README.md #13

Merged
farooqkz merged 1 commits from patch-1 into master 2017-11-28 18:32:38 +00:00
Showing only changes of commit 32f3d0057c - Show all commits

View File

@ -12,7 +12,7 @@ Install using npm:
npm install equations npm install equations
``` ```
####Examples: #### Examples:
```javascript ```javascript
// solve // solve
@ -53,28 +53,28 @@ For a list of operators and constants see [`operators.js`](https://github.com/md
API API
=== ===
####solve(expression: String) #### solve(expression: String)
Takes a math expression and evaluates it, returning the result. Takes a math expression and evaluates it, returning the result.
####equation(expression: String) #### equation(expression: String)
Takes a math expression containing variables, returning a function which Takes a math expression containing variables, returning a function which
replaces the variables with given arguments, and solves the expression. replaces the variables with given arguments, and solves the expression.
####registerOperator(key: String, options: Object) #### registerOperator(key: String, options: Object)
Registers a new operator. Registers a new operator.
Options: Options:
#####fn ##### fn
The function which is run on arguments and returns the result The function which is run on arguments and returns the result
#####format ##### format
The format which specifies how arguments are placed relative to operator, this is a string in which 1 represents the operator and zeroes represent arguments. The format which specifies how arguments are placed relative to operator, this is a string in which 1 represents the operator and zeroes represent arguments.
For example `+` has the format `010` and factorial has `01`. For example `+` has the format `010` and factorial has `01`.
#####precedence ##### precedence
Specifies the precedence of operator. The less the value, the higher the precedence, resulting in sooner execution. Specifies the precedence of operator. The less the value, the higher the precedence, resulting in sooner execution.
####registerConstant(key: String, value: Function/Number) #### registerConstant(key: String, value: Function/Number)
Registers a new constant. value can be a function (takes no arguments), or a constant number. Registers a new constant. value can be a function (takes no arguments), or a constant number.
That's right, we have named these *constants* but they actually can change, that's why we can use functions to define them. An example is the `RAND` constant which calls `Math.random`. That's right, we have named these *constants* but they actually can change, that's why we can use functions to define them. An example is the `RAND` constant which calls `Math.random`.