refactor: use a more idiomatic conditional set
This commit is contained in:
parent
2fe92c2ebf
commit
ad5293522d
1 changed files with 4 additions and 2 deletions
|
|
@ -9,12 +9,14 @@ const RETRIES = 2
|
||||||
const tickerObjects = {}
|
const tickerObjects = {}
|
||||||
|
|
||||||
function ticker (fiatCode, cryptoCode, tickerName) {
|
function ticker (fiatCode, cryptoCode, tickerName) {
|
||||||
const ticker = tickerObjects[tickerName] ?
|
if (!tickerObjects[tickerName]) {
|
||||||
tickerObjects[tickerName] :
|
|
||||||
tickerObjects[tickerName] = new ccxt[tickerName]({
|
tickerObjects[tickerName] = new ccxt[tickerName]({
|
||||||
timeout: 3000,
|
timeout: 3000,
|
||||||
enableRateLimit: false,
|
enableRateLimit: false,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const ticker = tickerObjects[tickerName]
|
||||||
|
|
||||||
if (verifyFiatSupport(fiatCode, tickerName)) {
|
if (verifyFiatSupport(fiatCode, tickerName)) {
|
||||||
return getCurrencyRates(ticker, fiatCode, cryptoCode)
|
return getCurrencyRates(ticker, fiatCode, cryptoCode)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue