INNER CODE UNIT · TypeScript

Promise

aelassas/movinin · packages/currency-converter/index.ts:521

      return new Promise((resolve, _) => {
        resolve(1)
      })
    } else {
      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

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…