tools/number/parser: return 0 if value undefined

This commit is contained in:
Chika 2022-07-08 19:42:21 +03:00
parent 46d63e490c
commit 06ba8566b7

View File

@ -1,6 +1,8 @@
/* eslint-disable implicit-arrow-linebreak */
export function parser(value?: string) {
const normalized = (value || '0').replace(/\s/g, '').replaceAll(',', '.');
if (!value) return 0;
const normalized = value.replace(/\s/g, '').replaceAll(',', '.');
return Number.parseFloat(normalized);
}