@depay/local-currency
Advanced tools
Comparing version 3.2.2 to 3.3.0
@@ -439,2 +439,9 @@ var timezoneToCurrency = { | ||
static async rate({ from, to }) { | ||
if(to == undefined) { to = Currency.getCode(); } | ||
let fromToUsd = await Currency.fromUSD({ amount: 1, code: from }); | ||
let toToUsd = await Currency.fromUSD({ amount: 1, code: to }); | ||
return fromToUsd.amount / toToUsd.amount | ||
} | ||
static async fromUSD({ amount, code, timeZone }) { | ||
@@ -441,0 +448,0 @@ let currency = new Currency({ amount, code, timeZone }); |
@@ -445,2 +445,9 @@ (function (global, factory) { | ||
static async rate({ from, to }) { | ||
if(to == undefined) { to = Currency.getCode(); } | ||
let fromToUsd = await Currency.fromUSD({ amount: 1, code: from }); | ||
let toToUsd = await Currency.fromUSD({ amount: 1, code: to }); | ||
return fromToUsd.amount / toToUsd.amount | ||
} | ||
static async fromUSD({ amount, code, timeZone }) { | ||
@@ -447,0 +454,0 @@ let currency = new Currency({ amount, code, timeZone }); |
{ | ||
"name": "@depay/local-currency", | ||
"moduleName": "LocalCurrency", | ||
"version": "3.2.2", | ||
"version": "3.3.0", | ||
"description": "JavaScript library that detects user's local currency and provides functionalities to convert between multiple currencies.", | ||
@@ -57,2 +57,3 @@ "main": "dist/umd/index.js", | ||
"fetch-mock": "^9.11.0", | ||
"jest-environment-jsdom": "^28.1.1", | ||
"node-fetch": "^2.6.1", | ||
@@ -59,0 +60,0 @@ "regenerator-runtime": "^0.13.7", |
@@ -59,2 +59,11 @@ ## Quickstart | ||
### rate | ||
Gets rate for given `from` and `to`: | ||
```javascript | ||
let rate = await Currency.rate({ from: 'EUR', to: 'GBP' }) | ||
// 1.1585365853658536 | ||
``` | ||
### getCode | ||
@@ -61,0 +70,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32550
935
91
24