Mathy.js is a simple arithmetic calculation engine for node.js and the browser.

It allows you to easily produce parameterized formulas and then get out the results based on what is passed in. It can also be used to execute a string as a formula. The library was written in TypeScript mostly because I wanted to see what it was like to write something in TypeScript. Don't worry though, the contents of the src folder includes the generated JavaScript as well as the source maps if you really want to debug the TypeScript.

Site note: The minified versions source map doesn't match by to the TypeScript source map as I can't get that working yet.

Mathy supports the idea of a binary choice, or decision, parameter, allowing you to have a parameter like this:

{
name: 'foo',
derivation: '1 === 1 ? 42 : 13'
}

The evaluation of this decision will be 42. The left and right sides of the decision can be made up of static values or they can be made up of other parameters, meaning you can have a decision like this: