UNPKG

cashify

Version:

Lightweight currency conversion library, successor of money.js

20 lines (19 loc) 665 B
import { Options } from './lib/options.js'; /** * Function, which converts currencies based on provided rates. * * @param {number | string} amount - Amount of money you want to convert. * @param {Object} options - Conversion options. * @param {new (value: BigSource) => Big} fn - Optional, Big.js constructor - useful to avoid floating point errors. * @return {number} Conversion result. * * @example * const rates = { * GBP: 0.92, * EUR: 1.00, * USD: 1.12 * }; * * convert(10, {from: 'EUR', to: 'GBP', base: 'EUR', rates}); //=> 9.2 */ export default function convert(amount: number | string, { from, to, base, rates, BigJs }: Options): number;