Class Currency

Monetary unit used to express a value.

Remarks

The minor unit of a currency, as described in the ISO 4217 standard, is the maximal size of the fractional part that can be used to describe the value when in a decimal form.

Example

For instance, US dollar has a minor unit of 2. This means that value in US dollar must be express with two digits after the decimal separator like in the following: 10.34

This can be done with the following instantiation:

const dollar = new Currency("dollar", 2);

Hierarchy

  • Currency

Implements

Constructors

Properties

Methods

Constructors

  • Creates a new instance of Currency.

    Parameters

    • name: string = ''

      name of the currency.

    • minorUnit: number = 0

      minor unit of the currency.

    Returns Currency

Properties

minorUnit: number = 0

minor unit of the currency.

name: string = ''

name of the currency.

Methods

  • Deserializes a Currency from an 'array of bytes'.

    Parameters

    • data: StaticArray<number>

      The 'array of bytes' to deserialize.

    • offset: number

      The position in the 'array of bytes' to start reading from.

    Returns Result<number>

    Result containing either an the new offset of the byte array or an Error.

  • Tests if two currencies are identical.

    Parameters

    • other: Currency

      Currency to check against.

    Returns boolean

    true if the currencies are identical.

    Remarks

    Two currencies are identical if they have the same 'minorUnit' as well as the same 'name'!

  • Tests if two currencies are different.

    Parameters

    • other: Currency

      Currency to check against.

    Returns boolean

    true if the currencies are different.

    Remarks

    Two currencies are different if they have the same 'name' but a different 'minorUnit' value!

Generated using TypeDoc