Skip to content

Javascript library to format numbers in a pretty human readable format

Notifications You must be signed in to change notification settings

JayashTripathy/pretty-count

Repository files navigation

npm version code style: prettier

Pretty Count

Javascript library to format numbers in a pretty human readable format

Installation

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

Parameters

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

Types

ScaleValue

export type ScaleValue = {
  value: number;
  shortSymbol?: string;
  symbol: string;
};

ScaleType

export type ScaleType = "standard" | "indian" | "eastAsian" 

About

Javascript library to format numbers in a pretty human readable format

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published