12 lines
300 B
TypeScript
12 lines
300 B
TypeScript
export function parser(value?: string) {
|
|
if (!value) return 0;
|
|
|
|
const normalized = value.replaceAll(/\s/gu, '').replaceAll(',', '.');
|
|
|
|
return Number.parseFloat(normalized);
|
|
}
|
|
|
|
export function round(value: number, precision: number = 0) {
|
|
return Number.parseFloat(value.toFixed(precision));
|
|
}
|