Home Reference Source Repository
import Currency from 'fincontracts-lib/src/currency.js'
public class | source

Currency

Currency class describes supported currencies as well as operations on them, such as mapping from and to a Currency index as well as exchanging a list of interval in different currencies to a single base for evaluation.

Static Member Summary

Static Public Members
public static get

Supported currencies as described in CurrenciesType.

public static get

Number of defined currencies in Currencies

Static Method Summary

Static Public Methods
public static

async changeAllCurrencies(base: String, currencies: Array): Object

Takes a currency base in ISO 4217 and a list of intervals in different currencies and transforms all to the specified base using http://fixer.io API

public static

convertToJSON(currencyList: Array): Object

Transforms an array of currency intervals to an object with bases as keys and corresponding intervals as values

public static

Given a currency name in ISO 4217, return its index from Currencies

Static Public Members

public static get Currencies: CurrenciesType source

Supported currencies as described in CurrenciesType.

public static get CurrencyCount: Number source

Number of defined currencies in Currencies

Static Public Methods

public static async changeAllCurrencies(base: String, currencies: Array): Object source

Takes a currency base in ISO 4217 and a list of intervals in different currencies and transforms all to the specified base using http://fixer.io API

Params:

NameTypeAttributeDescription
base String

a string specifiying currency from Currencies

currencies Array

an array of intervals in different currencies

Return:

Object

object with selected base as key and the calculated interval as value

public static convertToJSON(currencyList: Array): Object source

Transforms an array of currency intervals to an object with bases as keys and corresponding intervals as values

Params:

NameTypeAttributeDescription
currencyList Array

an array of intervals in different currencies

Return:

Object

transformed currencyList as object

public static getCurrencyIndex(currency: String): Number source

Given a currency name in ISO 4217, return its index from Currencies

Params:

NameTypeAttributeDescription
currency String

name in ISO 4217

Return:

Number

index from Currencies

Throw:

Error

If currency is not defined