Skip to content

Commit 107e588

Browse files
kael89mcccclean
andauthored
Release v1.0.1
* Update README.md * Update types Co-authored-by: Tom McLean <[email protected]>
1 parent 46f8ce2 commit 107e588

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# @beyondessential/arithmetic
22

3-
Utility to evaluate [BODMAS](https://en.wikipedia.org/wiki/Order_of_operations) arithmetic formulas
3+
Utility to evaluate [BODMAS](https://en.wikipedia.org/wiki/Order_of_operations) arithmetic formulas. It is an implementation of the [shunting yard algorithm](https://en.wikipedia.org/wiki/Shunting-yard_algorithm).
44

55
### Installation
66

@@ -15,5 +15,11 @@ yarn add beyondessential/arithmetic
1515
```js
1616
import { runArithmetic } from '@beyondessential/arithmetic';
1717

18-
runArithmetic('(1 + 2) / 3');
18+
const value = runArithmetic('(-1 + 2.5) / 3');
19+
console.log(value); // 0.5
20+
21+
const valueWithVariable = runArithmetic('2 * four', {
22+
four: 4
23+
});
24+
console.log(valueWithVariable); // 8
1925
```

index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export function runArithmetic(formula: string): number;
1+
export function runArithmetic(formula: string, values?: Record<string, string | number>): number;

0 commit comments

Comments
 (0)