Class Money
Index
Constructors
Properties
Methods
Constructors
constructor
Parameters
- value: MoneyParameter = "0"
Returns Money
Methods
format
format a price amount. extend # of decimals to specified # if not enough
Parameters
Optional
format: MoneyFormatOptions
Returns string
toJSON
Returns string
to Number
Returns number
to String
Returns string
Static
add
Static
check
Static
cmp
Compares two numbers
Parameters
- left: MoneyParameter
- right: MoneyParameter
Returns -1 | 0 | 1
Returns 0 if amount1 === amount2, -1 if amount1 < amount2, 1 if amount1 > amount2
Static
divide
Divides two values, (currently with up to 5 decimals of precision)
Parameters
- numerator: MoneyParameter
Value to divide
- divider: MoneyParameter
Returns Money
Divided value
- numerator: MoneyParameter
Static
from Number
Parameters
- value: number
Returns Money
Static
get Percentage
Returns a percentage of an amount
Parameters
- amount: MoneyParameter
Original amount
- percentage: MoneyParameter
Returns Money
Percentage of the amount
- amount: MoneyParameter
Static
is Money
Parameters
- value: unknown
Returns value is Money
Static
max
Returns the maximum of all the arguments
Parameters
- amount: MoneyParameter
First value
- ...amounts: MoneyParameter[]
Rest of the values
Returns Money
The highest value among amount and amounts
- amount: MoneyParameter
Static
min
Returns the minimum of all the arguments
Parameters
- amount: MoneyParameter
First value
- ...amounts: MoneyParameter[]
Rest of the values
Returns Money
The lowest value among amount and amounts
- amount: MoneyParameter
Static
multiply
Static
round To Multiple
Rounds a value to a multiple of a unit, with a specific rounding mode
Parameters
- amount: MoneyParameter
- roundto: MoneyParameter
- mode: MoneyRoundingMode
Rounding mode. Possible values:
- none: No rounding
- toward-zero: Round toward zero
- down: Round toward negative infity
- up: Round toward positive infity
- half-toward-zero: Round nearest multiple, round half of a multiple toward zero
- half-down: Round nearest multiple, round half of a multiple toward negative infinity
- half-up: Round nearest multiple, round half of a multiple toward positive infity
Returns Money
The rounded value
Static
subtract
Subtracts a number from another number
Parameters
- left: MoneyParameter
- right: MoneyParameter
Returns Money
A decimal based JS money type