ecency-mobile/src/utils/formatter.js
2020-03-24 12:52:23 +02:00

16 lines
318 B
JavaScript

export const makeCountFriendly = (value) => {
if (!value) {
return value;
}
if (value >= 1000000) {
return `${intlFormat(value / 1000000)}M`;
}
if (value >= 1000) {
return `${intlFormat(value / 1000)}K`;
}
return intlFormat(value);
};
const intlFormat = (num) => Math.round(num * 10) / 10;