Javascript library to format numbers in a pretty human readable format
Install Package
npm i pretty-count
Import utitlity
import pc from 'pretty-count';
Use the utility
pc(1000000) // 1million
pc(1000000000, {
scale: "indian",
showFullSymbol: false
}) //1Ar
Property | Type | Description | Default |
---|---|---|---|
scale |
ScaleType | Specifies the scale type to use. | standard |
customScale |
ScaleValue[] | An array of custom scale values to use instead of the predefined scales. | null |
prefix |
string |
A string to prepend to the formatted number. | "" |
suffix |
string |
A string to append to the formatted number. | "" |
roundingMethod |
round | floor | ceil | The method to use for rounding the number. | null |
seperator |
string |
The separator to use between number groups (e.g., thousands separator). | " " |
showFullSymbol |
boolean |
Whether to show the full symbol or use the short version. | true |
decimalPlaces |
number |
The number of decimal places to display in the formatted number. | 2 |
export type ScaleValue = {
value: number;
shortSymbol?: string;
symbol: string;
};
export type ScaleType = "standard" | "indian" | "eastAsian"