Skip to content

Releases: beyondessential/arithmetic

v2.1.1

05 Nov 22:27
f231616
Compare
Choose a tag to compare

v2.1.0

13 Oct 23:16
20f200f
Compare
Choose a tag to compare

Added support for the 'max' function

v2.0.0

31 Aug 00:17
2c3cd3a
Compare
Choose a tag to compare
  • Removed API: getOperands
  • Added API: getVariables(formulaText: string): string[]

v1.1.0

28 Aug 06:14
f3c58a5
Compare
Choose a tag to compare
  • Changed license to MIT

  • Added new API: getOperands(formulaText: string): string[]

v1.0.1

21 Aug 02:32
107e588
Compare
Choose a tag to compare
  • Update documentation and types

v1.0.0

21 Aug 01:03
Compare
Choose a tag to compare

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