Skip to content

Commit d8a2167

Browse files
committed
Simplify getRate function (move from options object to plain arguments)
1 parent 03142a6 commit d8a2167

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function hasKey<T>(obj: T, key: string | number | symbol): key is keyof T {
1212
return key in obj;
1313
}
1414

15-
const getRate = ({base, rates, from, to}: Options): number => {
15+
const getRate = (base: string, rates: object, from: string, to: string): number => {
1616
// If `from` equals `base`, return the basic exchange rate for the `to` currency
1717
if (from === base && hasKey(rates, to)) {
1818
return rates[to];
@@ -64,7 +64,7 @@ class Cashify {
6464
return amount;
6565
}
6666

67-
return (amount * 100) * getRate({base, rates, from, to}) / 100;
67+
return (amount * 100) * getRate(base, rates, from, to) / 100;
6868
}
6969
}
7070

@@ -83,7 +83,7 @@ const convert = (amount: number, {from, to, base, rates}: Options): number => {
8383
return amount;
8484
}
8585

86-
return (amount * 100) * getRate({base, rates, from, to}) / 100;
86+
return (amount * 100) * getRate(base, rates, from, to) / 100;
8787
};
8888

8989
export {

0 commit comments

Comments
 (0)