Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

ExchangeRate

ExchangeRate<Src, Dst>: { dst: Dst; ratio: Rational; src: Src }

Represents the ratio to convert a source currency to a destination currency

Type parameters

  • Src: string

  • Dst: string

Type declaration

  • Readonly dst: Dst

    the name of the target currency

  • Readonly ratio: Rational

    the ratio by which to multiply the source value to get the target value

  • Readonly src: Src

    the name of the source currency

Scale

Scale<Currency, Unit>: { currency: Currency; ratio: Rational; tag: Unit }

A scale is the ratio between any chosen unit and a currency main unit

Type parameters

  • Currency: string

  • Unit: string

Type declaration

  • currency: Currency

    the name of the currency

  • ratio: Rational

    the ratio between the scale unit and the currency main unit

  • tag: Unit

    the name of the scale unit

Functions

Const ceil

  • ceil<Currency, Unit, DenseVal>(value: DenseVal, scale: Scale<Currency, Unit>): [Discrete<Currency, Unit>, Dense<Currency>]
  • ceils the given dense value to the closest discrete value in the given scale

    Type parameters

    • Currency: string

    • Unit: string

    • DenseVal: Dense<Currency>

    Parameters

    • value: DenseVal

      the dense value

    • scale: Scale<Currency, Unit>

      the discrete scale

    Returns [Discrete<Currency, Unit>, Dense<Currency>]

Const exchange

  • exchange<Src, Dst, DenseSrc>(rate: ExchangeRate<Src, Dst>, src: DenseSrc): Dense<Dst>
  • converts a dense value from a source currency to a target currency based on the given exchange rate

    Type parameters

    • Src: string

    • Dst: string

    • DenseSrc: Dense<Src>

    Parameters

    • rate: ExchangeRate<Src, Dst>

      the exchange rate

    • src: DenseSrc

      a dense value in the source currency

    Returns Dense<Dst>

Const exchangeRate

  • create a new exchange rate

    Type parameters

    • Src: string

    • Dst: string

    Parameters

    • src: Src

      the source currency name

    • dst: Dst

      the target currency name

    • ratio: Rational

      the ratio by which to multiply the source value to get the target value

    Returns ExchangeRate<Src, Dst>

Const floor

  • floor<Currency, Unit, DenseVal>(value: DenseVal, scale: Scale<Currency, Unit>): [Discrete<Currency, Unit>, Dense<Currency>]
  • floors the given dense value to the closest discrete value in the given scale

    Type parameters

    • Currency: string

    • Unit: string

    • DenseVal: Dense<Currency>

    Parameters

    • value: DenseVal

      the dense value

    • scale: Scale<Currency, Unit>

      the discrete scale

    Returns [Discrete<Currency, Unit>, Dense<Currency>]

Const round

  • round<Currency, Unit, DenseVal>(value: DenseVal, scale: Scale<Currency, Unit>): [Discrete<Currency, Unit>, Dense<Currency>]
  • rounds the given dense value to the closest discrete value with the given scale

    Type parameters

    • Currency: string

    • Unit: string

    • DenseVal: Dense<Currency>

    Parameters

    • value: DenseVal

      the dense value

    • scale: Scale<Currency, Unit>

      the discrete scale

    Returns [Discrete<Currency, Unit>, Dense<Currency>]

Legend

Generated using TypeDoc