0.0.11 • Published 7 years ago

mathx v0.0.11

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

Mathx

Mathx is a library that represents a mathematical equation as a graph of dependencies. It uses the Mobx library to make properties observable.

Read the docs

Install

$ npm install --save mathx

or

$ yarn add mathx

Basic Usage

import {Mathx, autorun} from '../src';

const calc = Mathx.newCalculation();

// Add an equation to the calc
const a = calc.newEquation({
    symbol: 'a',
    formula: '10'
});

// This function will run once, immediately, then any time the value of `a` changes
autorun(() => {
    console.log('The value of a = ', a.value);
});
// => The value of a = 10

a.setFormula('5');
// => The value of a = 5

// Let's add another equation to the calc, this one will be dependent on the value of `a`
const b = calc.newEquation({
    symbol: 'b',
    formula: 'a + 5'
});

// setup another autorun function that observes `b`
autorun(() => {
    console.log('The value of b = ', b.value);
});
// => The value of b = 10

a.setFormula('10');
// => The value of b = 15
// => The value of a = 10

// The autorun function is called again, because the value of `b` depends on the value of `a`.

You can learn more by reading the documentation

Run the tests

clone the repo

$ git clone https://github.com/trevorhanus/mathx.git

install node modules

$ npm install

or

$ yarn install

run the all the tests

$ npm test

run one test individually

$ mocha --reporter spec --compilers ts:ts-node/register ./test/path/to/file.test.ts
0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago