🐛 fix(ui): Components
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { evaluate } from 'mathjs';
|
||||
import { evaluate, format } from 'mathjs';
|
||||
|
||||
export function unitConversion(
|
||||
type: 'centsToDollars' | 'dollarsToCents' | 'bitsToMb' | 'mbToBits' | 'bytesToGb' | 'gbToBytes',
|
||||
@@ -22,3 +22,11 @@ export function unitConversion(
|
||||
throw new Error('Invalid conversion type');
|
||||
}
|
||||
}
|
||||
|
||||
export function evaluateWithPrecision(expression: string) {
|
||||
const result = evaluate(expression);
|
||||
|
||||
const formatted = format(result, { notation: 'fixed', precision: 2 });
|
||||
|
||||
return Number(formatted);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user