UNPKG

cashify-es2017

Version:

Lightweight currency conversion library, successor of money.js

40 lines (39 loc) 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const convert_js_1 = require("./convert.js"); class Cashify { /** * @constructor * @param {Object} [options] Conversion options. */ constructor(options) { Object.defineProperty(this, "options", { enumerable: true, configurable: true, writable: true, value: options }); } /** * Function, which converts currencies based on provided rates. * * @param {number | string} amount - Amount of money you want to convert. * @param {Object} [options] - Conversion options. * @return {number} Conversion result. * * @example * const rates = { * GBP: 0.92, * EUR: 1.00, * USD: 1.12 * }; * * const cashify = new Cashify({base: 'EUR', rates}); * * cashify.convert(10, {from: 'EUR', to: 'GBP'}); //=> 9.2 */ convert(amount, options) { return (0, convert_js_1.default)(amount, Object.assign(Object.assign({}, this.options), options)); } } exports.default = Cashify;