shashank-currency-converter 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +15 -0
- package/package.json +26 -0
package/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Freecurrencyapi from '@everapi/freecurrencyapi-js';
|
|
2
|
+
|
|
3
|
+
const freecurrencyapi = new Freecurrencyapi('fca_live_ZDAUiX1pTtyjeiOIiPNgLr49oEAxURlysrmUmBur');
|
|
4
|
+
|
|
5
|
+
export async function convertCurrency(fromCurrency, toCurrency, units) {
|
|
6
|
+
|
|
7
|
+
const response = await freecurrencyapi.latest({
|
|
8
|
+
base_currency: fromCurrency,
|
|
9
|
+
currencies: toCurrency
|
|
10
|
+
});
|
|
11
|
+
const mulptiplier = response.data[toCurrency];
|
|
12
|
+
console.log(`Converting ${units} ${fromCurrency} to ${toCurrency}: ${units * mulptiplier}`);
|
|
13
|
+
return mulptiplier*units;
|
|
14
|
+
}
|
|
15
|
+
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "shashank-currency-converter",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "An npm package to convert currency",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"npm"
|
|
7
|
+
],
|
|
8
|
+
"homepage": "https://github.com/ShashankRajput01/npm#readme",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/ShashankRajput01/npm/issues"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/ShashankRajput01/npm.git"
|
|
15
|
+
},
|
|
16
|
+
"license": "Apache-2.0",
|
|
17
|
+
"author": "Shashank rajput",
|
|
18
|
+
"type": "module",
|
|
19
|
+
"main": "index.js",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "npm run test"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@everapi/freecurrencyapi-js": "^1.0.1"
|
|
25
|
+
}
|
|
26
|
+
}
|