Builds a widget for CodeStats

This commit is contained in:
Alicia Sykes
2021-12-16 23:33:27 +00:00
parent 599a5cc8d2
commit b7cd2d4c06
5 changed files with 295 additions and 0 deletions

View File

@@ -79,3 +79,15 @@ export const findCurrencySymbol = (currencyCode) => {
if (currencies[code]) return currencies[code];
return code;
};
/* Given a large number, will add commas to make more readable */
export const putCommasInBigNum = (bigNum) => {
const strNum = Number.isNaN(bigNum) ? bigNum : String(bigNum);
return strNum.replace(/\B(?=(?:\d{3})+(?!\d))/g, ',');
};
/* Given a large number, will convert 1000 into k for readability */
export const showNumAsThousand = (bigNum) => {
if (bigNum < 1000) return bigNum;
return `${Math.round(bigNum / 1000)}k`;
};