@icgio/icg-utils 1.9.33 → 1.9.35

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.
Files changed (2) hide show
  1. package/lib/forex-rate.js +11 -4
  2. package/package.json +1 -1
package/lib/forex-rate.js CHANGED
@@ -1,13 +1,20 @@
1
1
  const needle = require('needle')
2
2
  const utils = require('./utils.js')
3
3
 
4
- let get_forex_rate_usd = function (pair, cb) {
5
- let [cur, quote_cur] = utils.parse_pair(pair)
4
+ let get_forex_rate_usd = function (curs, cb) {
6
5
  needle.get(`https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/usd.json`, (err, res, body) => {
7
6
  if (body && body.usd) {
8
- cb(body.usd[quote_cur.toLowerCase()])
7
+ let rates = {}
8
+ for (let cur of curs) {
9
+ rates[cur] = 1 / body.usd[cur.toLowerCase()]
10
+ }
11
+ cb(rates)
9
12
  }
10
13
  })
11
14
  }
12
15
 
13
- module.exports.get_forex_rate = get_forex_rate_usd
16
+ module.exports.get_forex_rate_usd = get_forex_rate_usd
17
+
18
+ // get_forex_rate_usd(['BTC', 'CNY', 'HKD'], (rate) => {
19
+ // console.log(rate)
20
+ // })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-utils",
3
- "version": "1.9.33",
3
+ "version": "1.9.35",
4
4
  "description": "Utils package.",
5
5
  "main": "index.js",
6
6
  "directories": {