Added calculate to command entry for numbers - #66
Conversation
Codecov ReportBase: 14.34% // Head: 14.35% // Increases project coverage by
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## main #66 +/- ##
==========================================
+ Coverage 14.34% 14.35% +0.01%
==========================================
Files 43 43
Lines 5555 5585 +30
Branches 1111 1119 +8
==========================================
+ Hits 797 802 +5
- Misses 4272 4295 +23
- Partials 486 488 +2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
|
@dubstar-04 complete |
|
Cool feature. Need to consider the following: Order of operations (BIDMAS) : Negative numbers don't return a result: |
|
|
||
| calculate(string) { | ||
| // define the regular expression to match the operators | ||
| const operators = /^(\d+(\.\d+)?|\((\s*\d+(\.\d+)?\s*[\+\-\*\/]\s*)+\d+(\.\d+)?\))(\s*[\+\-\*\/]\s*(\d+(\.\d+)?|\((\s*\d+(\.\d+)?\s*[\+\-\*\/]\s*)+\d+(\.\d+)?\)))*$/; |
There was a problem hiding this comment.
Should be able to distil this down to a much simpler expression.
|
it could be possible to simplify calculations. This is janky but shows an extreme example: const input = '4+2*5'; |
|
AutoCAD Expressions, use the CAL command: |

Screencast.from.16-02-23.21.16.50.webm
New feature for calculating values as you enter the command.
Works for anything that is a number