You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
503 B

export const abbreviateNumber = (value: number): string => {
const suffixes = ["", "K", "M", "B", "T"];
let suffixNum = 0;
while (value >= 1000) {
value /= 1000;
suffixNum++;
}
value = parseInt(value.toPrecision(3));
return `${value}${suffixes[suffixNum]}`;
};
export const toCamelCase = (string: string): string =>
string
.replace(/(?:^\w|[A-Z]|\b\w)/g, (leftTrim: string, index: number) =>
index === 0 ? leftTrim.toLowerCase() : leftTrim.toUpperCase()
)
.replace(/\s+/g, "");