Skip to content

Format Money #14

@f3oall

Description

@f3oall

What problem is this solving

Currency Formatting

Proposed solution

export type Separators = {
  thousands: string
  decimal: string
}

export type Currency = string

export function toCurrency(num: string | number | BigInt, currency: string = toCurrency.currency, precision: number = toCurrency.precision,  separators: Separators = toCurrency.separators) : Currency {}
toCurrency.prototype.currency = "$"
toCurrency.prototype.precision = 2
toCurrency.prototype.separators = {thousands: ".", decimal: ","}

export function fromCurrency(value: Currency) : BigInt {}
//Example
let currency = toCurrency(100000.83) // result: "$100,000.83"
let number = fromCurrency(currency) // result 100000.83

Check accounting.js as reference

Describe alternatives you've considered

No response

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions