@barchart/common-js
Version:
Library of common JavaScript utilities
52 lines (51 loc) • 1.46 kB
TypeScript
/**
* A calculator that translates an amount of one currency into an amount
* in another currency. The calculator prefers to use direct conversions;
* however, it supports indirect conversions (which require conversions
* to one or more intermediate currencies before translation to the final,
* desired currency).
*
* @public
*/
export default class CurrencyTranslator {
/**
* @param {string[]} symbols - Forex symbols which will be used for translations.
*/
constructor(symbols: string[]);
/**
* Updates the calculator with new rates.
*
* @public
* @param {Rate[]} rates
*/
public setRates(rates: Rate[]): void;
/**
* Updates the calculator with a new rate.
*
* @public
* @param {Rate} rate
*/
public setRate(rate: Rate): void;
/**
* Performs a currency translation, using the rates previously supplied to
* the calculator.
*
* @public
* @param {number|Decimal} amount
* @param {Currency} current
* @param {Currency} desired
* @returns {number|Decimal}
*/
public translate(amount: number | Decimal, current: Currency, desired: Currency): number | Decimal;
/**
* Returns a string representation.
*
* @public
* @returns {string}
*/
public toString(): string;
#private;
}
import Rate from './Rate.js';
import Decimal from './Decimal.js';
import Currency from './Currency.js';