INNER CODE UNIT · TypeScript
currencyPair
aelassas/movinin · packages/currency-converter/index.ts:525
let currencyPair = this.currencyFrom.toUpperCase() + this.currencyTo.toUpperCase()
let now = new Date()
if (currencyPair in this.ratesCache && now < this.ratesCache[currencyPair].expiryDate) {
return new Promise((resolve, _) => {
resolve(this.ratesCache[currencyPair].rate)
})
} else {
return new Promise((resolve, reject) => {
Convert(this.currencyAmount).from(this.currencyFrom).to(this.currencyTo)
.then((res) => resolve(res))
.catch((err) => reject(err))
})
.then((rates: unknown) => {
const ratesNum = rates as number / this.currencyAmount
if (this.isRatesCaching) {
this.addRateToRatesCache(currencyPair, ratesNum)
}
return ratesNum