ecency-mobile/src/utils/formatter.js
2019-11-29 20:13:50 +02:00

16 lines
314 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;