format library

Pakistani Rupee and lakh/crore formatting.

Same as the pakdatakit/format entry point of the npm package.

Classes

ParsedAmount
The result of parseAmount.

Functions

formatAmountInput(String input) → String?
Writes back an amount typed in any form parseAmount accepts, for showing next to the field ("= Rs. 150,000"): Rs., international grouping, and paisa only when there are any (Rs. 1,234.50). Returns null when parseAmount does; it never throws.
formatLakh(num amount) → String
Formats an amount using Pakistani lakh/crore conventions.
formatPKR(num amount) → String
Formats an amount as Pakistani Rupees with comma separators, rounded to whole rupees: "Rs. 150,000". Negative amounts are prefixed with - ("-Rs. 500").
parseAmount(String input) → ParsedAmount?
Reads a rupee amount the way people type it in Pakistan, and returns it in rupees, rounded half-up to the paisa. Returns null for anything that is not exactly one non-negative amount; it never throws.