Skip to content

Commit 706f4d7

Browse files
refactor: change property name from abbreviation to notation for code readability
1 parent ec9aa94 commit 706f4d7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/utilities/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ export function sleep(ms: number): Promise<unknown> {
1515
*/
1616
export const shortenNumber = (amount: number) => {
1717
const abreviations = [
18-
{ value: 1000000000, abbreviation: "B" },
19-
{ value: 1000000, abbreviation: "M" },
20-
{ value: 1000, abbreviation: "K" },
18+
{ value: 1000000000, notation: "B" },
19+
{ value: 1000000, notation: "M" },
20+
{ value: 1000, notation: "K" },
2121
];
2222

2323
const abbreviation = abreviations.find(({ value }) => amount >= value);
@@ -26,5 +26,5 @@ export const shortenNumber = (amount: number) => {
2626

2727
const product = amount / abbreviation.value;
2828
const isFloat = product % 1 !== 0;
29-
return `${isFloat ? product.toFixed(1) : product}${abbreviation.abbreviation}`;
29+
return `${isFloat ? product.toFixed(1) : product}${abbreviation.notation}`;
3030
};

0 commit comments

Comments
 (0)