Skip to content

v1.0.0

Compare
Choose a tag to compare
@kael89 kael89 released this 21 Aug 01:03
· 7 commits to master since this release

Api

runArithmetic(formula: string, values?: Record<string, string | number>): number;

formula must be in BODMAS format.

Usage example:

import { runArithmetic } from '@beyondessential/arithmetic';

const value = runArithmetic('(-1 + 2.5) / 3');
console.log(value); // 0.5

const valueWithVariable = runArithmetic('2 * four', {
  four: 4
});
console.log(valueWithVariable); // 8