aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorOgnjen Jevremovic <[email protected]>2021-02-28 19:09:35 +0100
committerOgnjen Jevremovic <[email protected]>2021-02-28 19:09:35 +0100
commitf6b3ef94ecc1f37feb56bd4a41e9c65e962b4bd1 (patch)
tree8a2f7afc43c02ce0acd8433e37662283866c0078 /lib
parentf5f186c70d6c57d41aa34ab82aae554d70ef7c7f (diff)
downloadfaker-f6b3ef94ecc1f37feb56bd4a41e9c65e962b4bd1.tar.xz
faker-f6b3ef94ecc1f37feb56bd4a41e9c65e962b4bd1.zip
perf: ⚡️ Optimize finance transaction description method
Remove the multiple calls to `createTransaction` method from within the `finance.transactionDescription` and instead call the method once and reference the properties from the returned transaction object. ✅ Closes: #1108
Diffstat (limited to 'lib')
-rw-r--r--lib/finance.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/finance.js b/lib/finance.js
index bbe2b17f..43fe6710 100644
--- a/lib/finance.js
+++ b/lib/finance.js
@@ -338,14 +338,15 @@ self.litecoinAddress = function () {
* @method faker.finance.transactionDescription
*/
self.transactionDescription = function() {
- var account = Helpers.createTransaction().account
+ var transaction = Helpers.createTransaction();
+ var account = transaction.account;
+ var amount = transaction.amount;
+ var transactionType = transaction.type;
+ var company = transaction.business;
var card = faker.finance.mask();
var currency = faker.finance.currencyCode();
- var amount = Helpers.createTransaction().amount
- var transactionType = Helpers.createTransaction().type
- var company = Helpers.createTransaction().business
return transactionType + " transaction at " + company + " using card ending with ***" + card + " for " + currency + " " + amount + " in account ***" + account
- }
+ };
};