xchange-rates 2025.8.16-1 → 2025.8.17-2

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.
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { xchangerate } from '../index.js';
4
+
5
+ const args = process.argv.slice(2);
6
+
7
+ if (args.length < 2) {
8
+ console.log('Usage: xchangerate <baseCurrency> <targetCurrency> [--local]');
9
+ process.exit(1);
10
+ }
11
+
12
+ const [baseCurrency, targetCurrency, ...flags] = args;
13
+ const useCDN = !flags.includes('--local');
14
+
15
+ xchangerate(baseCurrency, targetCurrency, useCDN)
16
+ .then(result => {
17
+ console.log(JSON.stringify(result, null, 2));
18
+ })
19
+ .catch(err => {
20
+ console.error('Error:', err.message);
21
+ process.exit(1);
22
+ });
package/index.js CHANGED
@@ -5,14 +5,14 @@ import fetch from 'node-fetch';
5
5
  const localPath = path.resolve('./v1/currencies.json');
6
6
  let localRates = fs.existsSync(localPath) ? JSON.parse(fs.readFileSync(localPath, 'utf-8')) : null;
7
7
 
8
- export async function xchangerate(baseCurrency, targetCurrency, useCDN = false) {
8
+ export async function xchangerate(baseCurrency, targetCurrency, useCDN = true) {
9
9
  baseCurrency = baseCurrency.toUpperCase();
10
10
  targetCurrency = targetCurrency.toUpperCase();
11
11
 
12
12
  let data;
13
13
 
14
14
  if (useCDN) {
15
- const res = await fetch('https://cdn.jsdelivr.net/npm/@jayadevpanthaplavil/xchange-rates@latest/v1/currencies.json');
15
+ const res = await fetch('https://cdn.jsdelivr.net/npm/xchange-rates@latest/v1/currencies.json');
16
16
  data = await res.json();
17
17
  } else {
18
18
  if (!localRates) throw new Error('Local JSON not available');
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "xchange-rates",
3
- "version": "2025.8.16-1",
3
+ "version": "2025.8.17-2",
4
4
  "description": "A lightweight Node.js package to get real-time currency exchange rates for any base currency using a pivot currency, fetched directly from a CDN for fast and reliable access.",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
+ "bin": {
8
+ "xchangerate": "./bin/xchangerate.js"
9
+ },
7
10
  "scripts": {
8
11
  "update": "node scripts/updateRates.js",
9
12
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -1,5 +1,5 @@
1
1
  {
2
- "timestamp": 1755331205,
2
+ "timestamp": 1755421206,
3
3
  "base": "USD",
4
4
  "rates": {
5
5
  "AED": 3.67295,
@@ -23,20 +23,20 @@
23
23
  "BOB": 6.907525,
24
24
  "BRL": 5.4013,
25
25
  "BSD": 1,
26
- "BTC": 0.000008496902,
26
+ "BTC": 0.000008445528,
27
27
  "BTN": 87.426851,
28
28
  "BWP": 13.378101,
29
- "BYN": 3.323768,
29
+ "BYN": 3.334902,
30
30
  "BZD": 2.00793,
31
31
  "CAD": 1.38215,
32
32
  "CDF": 2895,
33
33
  "CHF": 0.806593,
34
- "CLF": 0.024586,
34
+ "CLF": 0.024552,
35
35
  "CLP": 963.17,
36
36
  "CNH": 7.1854,
37
37
  "CNY": 7.1821,
38
38
  "COP": 4046.904675,
39
- "CRC": 505.848441,
39
+ "CRC": 505.132789,
40
40
  "CUC": 1,
41
41
  "CUP": 25.75,
42
42
  "CVE": 94.9,
@@ -70,7 +70,7 @@
70
70
  "IMP": 0.73749,
71
71
  "INR": 87.51385,
72
72
  "IQD": 1310,
73
- "IRR": 42125,
73
+ "IRR": 42112.5,
74
74
  "ISK": 122.38,
75
75
  "JEP": 0.73749,
76
76
  "JMD": 159.957172,
@@ -86,7 +86,7 @@
86
86
  "KYD": 0.83302,
87
87
  "KZT": 541.496827,
88
88
  "LAK": 21600,
89
- "LBP": 89552.5,
89
+ "LBP": 89181.146416,
90
90
  "LKR": 300.889726,
91
91
  "LRD": 201.499983,
92
92
  "LSL": 17.59,
@@ -97,14 +97,14 @@
97
97
  "MKD": 52.634726,
98
98
  "MMK": 2099,
99
99
  "MNT": 3592.646,
100
- "MOP": 8.081343,
100
+ "MOP": 8.055945,
101
101
  "MRU": 39.95,
102
- "MUR": 45.520003,
103
- "MVR": 15.4,
102
+ "MUR": 45.58,
103
+ "MVR": 15.41,
104
104
  "MWK": 1735,
105
105
  "MXN": 18.7435,
106
106
  "MYR": 4.213,
107
- "MZN": 63.959999,
107
+ "MZN": 63.899993,
108
108
  "NAD": 17.59,
109
109
  "NGN": 1532.72,
110
110
  "NIO": 36.76,
@@ -115,10 +115,10 @@
115
115
  "PAB": 1,
116
116
  "PEN": 3.56,
117
117
  "PGK": 4.14,
118
- "PHP": 57.107006,
118
+ "PHP": 56.553002,
119
119
  "PKR": 282.05,
120
120
  "PLN": 3.638739,
121
- "PYG": 7492.814679,
121
+ "PYG": 7320.89017,
122
122
  "QAR": 3.6406,
123
123
  "RON": 4.3258,
124
124
  "RSD": 100.188013,
@@ -129,9 +129,9 @@
129
129
  "SCR": 14.145453,
130
130
  "SDG": 600.5,
131
131
  "SEK": 9.5588,
132
- "SGD": 1.282874,
132
+ "SGD": 1.280713,
133
133
  "SHP": 0.73749,
134
- "SLE": 23.225,
134
+ "SLE": 23.3,
135
135
  "SLL": 20969.5,
136
136
  "SOS": 571.5,
137
137
  "SRD": 37.56,
@@ -141,7 +141,7 @@
141
141
  "SVC": 8.746792,
142
142
  "SYP": 13002,
143
143
  "SZL": 17.59,
144
- "THB": 32.420657,
144
+ "THB": 32.426198,
145
145
  "TJS": 9.321609,
146
146
  "TMT": 3.51,
147
147
  "TND": 2.921557,
@@ -160,7 +160,7 @@
160
160
  "VUV": 119.1167,
161
161
  "WST": 2.7716,
162
162
  "XAF": 560.415306,
163
- "XAG": 0.02631337,
163
+ "XAG": 0.0263091,
164
164
  "XAU": 0.00029985,
165
165
  "XCD": 2.70255,
166
166
  "XCG": 1.801625,
@@ -175,5 +175,5 @@
175
175
  "ZWG": 26.78,
176
176
  "ZWL": 322
177
177
  },
178
- "date": "2025-08-16"
178
+ "date": "2025-08-17"
179
179
  }