Fix number conversion

This commit is contained in:
2020-06-11 22:33:44 +03:00
parent 1f58da5d58
commit 625e7f9836
2 changed files with 27 additions and 2 deletions

View File

@ -82,8 +82,8 @@ export function* split(n: number, from: number = 2, to: number = 6) {
export function toNumber(value: any): number | undefined {
const normalized = String(value)
.replace('', '-')
.replace(/[^0-9-]/gi, '');
.replace('\u2212', '\u002d') // minus to hyphen-minus
.replace(/[^0-9\u002d]/g, '');
const converted = Number(normalized);
return isNaN(converted) ? undefined : converted;
}