🐛 fix(ui): Components

This commit is contained in:
web@ppanel
2024-11-15 01:39:47 +07:00
parent 727d779b84
commit a7927d701a
12 changed files with 170 additions and 171 deletions
+9 -1
View File
@@ -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);
}