Skip to content

Commit

Permalink
chore: improve function name
Browse files Browse the repository at this point in the history
  • Loading branch information
hirsch88 committed May 23, 2024
1 parent 07f9a1b commit dc62600
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { ACTION_KEYS, NUMBER_KEYS } from '../../utils/constants/keys.constant'
import { formatLocaleNumber, getDecimalSeparator, getNegativeSymbol, getThousandSeparator } from '../../utils/number'
import isNaN from 'lodash.isnan'

function checkIfValueIsStringAndDoesNotHaveGermanFormat(val: any): boolean {
return typeof val === 'string' && getThousandSeparator() !== '.'
}

export function isNumber(value: any): boolean {
const num = parseFloat(value)
return typeof num === 'number' && !isNaN(num)
Expand All @@ -26,7 +30,7 @@ export function toNumber(value: any, decimalPoints = 0): number | undefined {
return undefined
}

if (typeof val === 'string' && getThousandSeparator() !== '.') {
if (checkIfValueIsStringAndDoesNotHaveGermanFormat(val)) {
val = val.split(getThousandSeparator()).join('').split('`').join('').split("'").join('')
}

Expand All @@ -39,7 +43,7 @@ export function toFixedNumber(value: string, decimalPoints = 0): string {
return ''
}

if (typeof val === 'string' && getThousandSeparator() !== '.') {
if (checkIfValueIsStringAndDoesNotHaveGermanFormat(val)) {
val = val.split(getThousandSeparator()).join('').split('`').join('').split("'").join('')
}

Expand Down

0 comments on commit dc62600

Please sign in to comment.