UNPKG

convert-to-compact

Version:

A utility to convert large numbers into K, M, or B format

19 lines (10 loc) 477 B
--- ### **Code Explanation** **`convertToKMB(amount: number)`**: - **Purpose**: Converts large numbers into readable abbreviations (K, M, B). - **Logic**: - If the number is in the range of thousands (6 digits), it appends 'K'. - If the number is in the range of millions (7–9 digits), it appends 'M'. - If the number is in the range of billions (10–12 digits), it appends 'B'. - Numbers less than 1,000 are returned as a string without modification. ---