Skip to content

Commit 5c1dee3

Browse files
committed
When from equals to, return the basic exchange rate for the to currency
1 parent 400090a commit 5c1dee3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ function hasKey<T>(obj: T, key: keyof any): key is keyof T {
1313

1414
const getRate = ({base, rates, from, to}: Options): number => {
1515
if (hasKey(rates, to)) {
16-
// If `from` equals `base`, return the basic exchange rate for the `to` currency
17-
if (from === base) {
16+
// If `from` equals `base` or `from` equals `to`, return the basic exchange rate for the `to` currency
17+
if (from === base || from === to) {
1818
return rates[to];
1919
}
2020

0 commit comments

Comments
 (0)