ecency-mobile/src/utils/formatter.js

16 lines
318 B
JavaScript
Raw Normal View History

2020-03-24 13:52:23 +03:00
export const makeCountFriendly = (value) => {
2019-11-29 21:13:50 +03:00
if (!value) {
return value;
}
if (value >= 1000000) {
return `${intlFormat(value / 1000000)}M`;
}
if (value >= 1000) {
return `${intlFormat(value / 1000)}K`;
}
return intlFormat(value);
};
2020-03-24 13:52:23 +03:00
const intlFormat = (num) => Math.round(num * 10) / 10;