Skip to content

Commit 3c6c54c

Browse files
author
Olga Davydova
committed
Fixed long numbers format for objects and arrays
1 parent 988de53 commit 3c6c54c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

web/frontend/src/app/shared/utils/digitGrouping.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export function formatArray(array: any[], locale: string) {
22
return array.map(item => {
3-
if (['number', 'string'].includes(typeof item) && Math.abs(item) >= 1000) {
3+
if (Math.abs(item) >= 1000 && Math.abs(item) <= Number.MAX_SAFE_INTEGER) {
44
return parseFloat(item).toLocaleString(locale);
55
} else if (item && typeof item === 'object') {
66
return formatObject(item, locale);
@@ -16,7 +16,7 @@ export function formatObject(object: object, locale: string) {
1616
return Object.fromEntries(
1717
Object.entries(object).map(([key, value]) => {
1818
let formattedValue = value;
19-
if (['number', 'string'].includes(typeof value) && Math.abs(value) >= 1000) {
19+
if (Math.abs(value) >= 1000 && Math.abs(value) <= Number.MAX_SAFE_INTEGER) {
2020
formattedValue = parseFloat(value).toLocaleString(locale);
2121
} else if (value && typeof value === 'object') {
2222
formattedValue = formatObject(value, locale);

0 commit comments

Comments
 (0)