import Money from '../Money'; export interface CurrencyFormatter { (settings: { value: Money; defaultFormatted: string; symbol: string; code: string; decimalDigits: number; thousandsSeparator: string; decimalSeparator: string; pattern: string; }): string; } export interface CurrencyParser { (settings: { symbol: string; code: string; thousandsSeparator: string; decimalSeparator: string; decimalDigits: number; pattern: string; value: string; defaultParsed: Money; }): Money; } export interface CurrencySettings { thousandsSeparator: string; decimalSeparator: string; decimalDigits: number; pattern: string; symbol: string; formatter?: CurrencyFormatter; parser?: CurrencyParser; code: string; } export interface CurrencyInputSettings { thousandsSeparator?: string; decimalSeparator?: string; decimalDigits?: number; pattern?: string; symbol?: string; formatter?: CurrencyFormatter; parser?: CurrencyParser; code: string; } /** * @example * Using code * ```js * let currency = new Currency('USD'); * ``` * * @example * Using existing currency object * ```js * let currency = new Currency(new Currency('USD')); * ``` * * @example * Using custom settings to create * a one-off currency without registering it * ```js * let currency = new Currency({ * code: 'ETH', * symbol: 'Ξ' * }); * ``` */ export default class Currency { thousandsSeparator: string; decimalSeparator: string; decimalDigits: number; pattern: string; symbol: string; formatter?: CurrencyFormatter; parser?: CurrencyParser; code: string; /** * @param currency - Currency string code, custom settings or instance of Currency */ constructor(currency: string | CurrencyInputSettings | Currency); /** * Check if the parameter currency is the same as the current currency * @param currency - Currency string code or instance of Currency * @returns - returns true if the parameter currency is the same as the current currency */ is(currency: string | Currency): boolean; /** * Get currency code * @returns - Currency code */ toString(): string; /** * Get currency code * @returns - Currency code */ toJSON(): string; /** * Clone the currency instance * @returns - new Currency instance */ clone(): Currency; /** * Get settings * @returns - Currency settings */ readonly settings: CurrencySettings; /** * Used by the constructor to pre-process the input * @param currency - Currency code, settings or instance of Currency * @returns - Currency settings */ private preProcess; /** * Creates a new instance of Currency * @param currency - Currency string code, custom settings or instance of Currency */ static init(currency: string | CurrencyInputSettings | Currency): Currency; }