Skip to content

Commit 9bcb338

Browse files
committed
remove lodash.map() calls
find packages/ -type f -exec sed -i -E \ -e 's/_\.map\(([^,]+), function\(([^,\)]*)\) \{/\1.map(\2 => {/g' {} + find packages/ -type f -exec sed -i -E \ -e 's/_\.map\(([^,]+), function(\([^\)]*\)) \{/\1.map(\2 => {/g' {} + find packages/ -type f -exec sed -i -E \ -e 's/_[.]map\(([^,]+), ([a-zA-Z]+) => \{/\1.map(\2 => {/g' {} + find packages/ -type f -exec sed -i -E \ -e 's/_[.]map\(([^,]+), ([a-zA-Z]+ => [^\{])/\1.map(\2/g' {} +
1 parent aa6cefe commit 9bcb338

File tree

16 files changed

+65
-65
lines changed

16 files changed

+65
-65
lines changed

packages/bitcore-lib/lib/transaction/input/multisig.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ inherits(MultiSigInput, Input);
4444
MultiSigInput.prototype.toObject = function() {
4545
var obj = Input.prototype.toObject.apply(this, arguments);
4646
obj.threshold = this.threshold;
47-
obj.publicKeys = _.map(this.publicKeys, function(publicKey) { return publicKey.toString(); });
47+
obj.publicKeys = this.publicKeys.map(publicKey => publicKey.toString());
4848
obj.signatures = this._serializeSignatures();
4949
return obj;
5050
};
5151

5252
MultiSigInput.prototype._deserializeSignatures = function(signatures) {
53-
return _.map(signatures, function(signature) {
53+
return signatures.map(signature => {
5454
if (!signature) {
5555
return undefined;
5656
}
@@ -59,7 +59,7 @@ MultiSigInput.prototype._deserializeSignatures = function(signatures) {
5959
};
6060

6161
MultiSigInput.prototype._serializeSignatures = function() {
62-
return _.map(this.signatures, function(signature) {
62+
return this.signatures.map(signature => {
6363
if (!signature) {
6464
return undefined;
6565
}

packages/bitcore-wallet-service/src/lib/bchaddresstranslator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class BCHAddressTranslator {
3434
ret = addresses;
3535
} else {
3636
ret = _.filter(
37-
_.map(addresses, x => {
37+
addresses.map(x => {
3838
const bitcore = Bitcore_[from == 'legacy' ? 'btc' : 'bch'];
3939
let orig;
4040

packages/bitcore-wallet-service/src/lib/chain/btc/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ export class BtcChain implements IChain {
432432
'Failed state: t.outputs.length not equal to outputOrder.length at <getBitcoreTx()>'
433433
);
434434
t.sortOutputs(outputs => {
435-
return _.map(outputOrder, i => {
435+
return outputOrder.map(i => {
436436
return outputs[i];
437437
});
438438
});

packages/bitcore-wallet-service/src/lib/model/address.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export class Address {
108108
}
109109
}
110110

111-
let publicKeys = _.map(publicKeyRing, item => {
111+
let publicKeys = publicKeyRing.map(item => {
112112
const xpub = Address.Bitcore[chain]
113113
? new Address.Bitcore[chain].HDPublicKey(item.xPubKey)
114114
: new Address.Bitcore.btc.HDPublicKey(item.xPubKey);

packages/bitcore-wallet-service/src/lib/model/txproposal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ export class TxProposal {
331331
x.txids = obj.txids;
332332
x.broadcastedOn = obj.broadcastedOn;
333333
x.inputPaths = obj.inputPaths;
334-
x.actions = _.map(obj.actions, action => {
334+
x.actions = obj.actions.map(action => {
335335
return TxProposalAction.fromObj(action);
336336
});
337337
x.outputOrder = obj.outputOrder;
@@ -421,7 +421,7 @@ export class TxProposal {
421421
return a.type == 'accept';
422422
});
423423

424-
return _.map(acceptedActions, x => {
424+
return acceptedActions.map(x => {
425425
return {
426426
signatures: x.signatures,
427427
xpub: x.xpub

packages/bitcore-wallet-service/src/lib/model/txproposal_legacy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export class TxProposalLegacy {
117117
x.txid = obj.txid;
118118
x.broadcastedOn = obj.broadcastedOn;
119119
x.inputPaths = obj.inputPaths;
120-
x.actions = _.map(obj.actions, function(action) {
120+
x.actions = obj.actions.map(action => {
121121
return TxProposalAction.fromObj(action);
122122
});
123123
x.outputOrder = obj.outputOrder;

packages/bitcore-wallet-service/src/lib/model/wallet.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export class Wallet {
156156
x.singleAddress = !!obj.singleAddress;
157157
x.status = obj.status;
158158
x.publicKeyRing = obj.publicKeyRing;
159-
x.copayers = _.map(obj.copayers, copayer => {
159+
x.copayers = obj.copayers.map(copayer => {
160160
return Copayer.fromObj(copayer);
161161
});
162162
x.pubKey = obj.pubKey;
@@ -235,7 +235,7 @@ export class Wallet {
235235
}
236236

237237
_updatePublicKeyRing() {
238-
this.publicKeyRing = _.map(this.copayers, copayer => {
238+
this.publicKeyRing = this.copayers.map(copayer => {
239239
return _.pick(copayer, ['xPubKey', 'requestPubKey']);
240240
});
241241
}

packages/bitcore-wallet-service/src/lib/pushnotificationsservice.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export class PushNotificationsService {
206206
this._getSubscriptions(notification, notifType, recipientsList, contents, next);
207207
},
208208
(subs, next) => {
209-
const notifications = _.map(subs, sub => {
209+
const notifications = subs.map(sub => {
210210
if (notification.type === 'NewTxProposal' && sub.copayerId === notification.creatorId) return;
211211

212212
const tokenAddress =
@@ -386,7 +386,7 @@ export class PushNotificationsService {
386386
if (_.isEmpty(preferences)) preferences = [];
387387

388388
const recipientPreferences = _.compact(
389-
_.map(preferences, p => {
389+
preferences.map(p => {
390390
if (!_.includes(this.availableLanguages, p.language)) {
391391
if (p.language) logger.warn('Language for notifications "' + p.language + '" not available.');
392392
p.language = this.defaultLanguage;
@@ -403,7 +403,7 @@ export class PushNotificationsService {
403403
const copayers = _.keyBy(recipientPreferences, 'copayerId');
404404

405405
const recipientsList = _.compact(
406-
_.map(wallet.copayers, copayer => {
406+
wallet.copayers.map(copayer => {
407407
const p = copayers[copayer.id] || {
408408
language: this.defaultLanguage,
409409
unit: this.defaultUnit
@@ -565,7 +565,7 @@ export class PushNotificationsService {
565565
}
566566

567567
if (notification.type == 'TxProposalFinallyRejected' && data.rejectedBy) {
568-
const rejectors = _.map(data.rejectedBy, copayerId => {
568+
const rejectors = data.rejectedBy.map(copayerId => {
569569
return wallet.copayers.find(c => c.id === copayerId).name;
570570
});
571571
data.rejectorsNames = rejectors.join(', ');

packages/bitcore-wallet-service/src/lib/stats.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class Stats {
9393
.toArray((err, results) => {
9494
if (err) return cb(err);
9595
const stats = {
96-
byDay: _.map(results, record => {
96+
byDay: results.map(record => {
9797
const day = moment(record._id.day).format('YYYYMMDD');
9898
return {
9999
day,
@@ -123,7 +123,7 @@ export class Stats {
123123
.toArray((err, results) => {
124124
if (err) return cb(err);
125125
const stats = {
126-
byDay: _.map(results, record => {
126+
byDay: results.map(record => {
127127
const day = moment(record._id.day).format('YYYYMMDD');
128128
return {
129129
day,

packages/bitcore-wallet-service/src/lib/storage.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ export class Storage {
237237
}
238238

239239
storeWalletAndUpdateCopayersLookup(wallet, cb) {
240-
const copayerLookups = _.map(wallet.copayers, copayer => {
240+
const copayerLookups = wallet.copayers.map(copayer => {
241241
try {
242242
$.checkState(
243243
copayer.requestPubKeys,
@@ -368,7 +368,7 @@ export class Storage {
368368
.toArray((err, result) => {
369369
if (err) return cb(err);
370370
if (!result) return cb();
371-
const txs = _.map(result, tx => {
371+
const txs = result.map(tx => {
372372
return TxProposal.fromObj(tx);
373373
});
374374
return cb(null, txs);
@@ -391,7 +391,7 @@ export class Storage {
391391
const multisigTxpsInfoByTransactionHash: any = _.groupBy(multisigTxpsInfo, 'transactionHash');
392392
const actionsById = {};
393393
const txs = _.compact(
394-
_.map(result, tx => {
394+
result.map(tx => {
395395
if (!tx.multisigContractAddress) {
396396
return undefined;
397397
}
@@ -434,7 +434,7 @@ export class Storage {
434434
.toArray((err, result) => {
435435
if (err) return cb(err);
436436
if (!result) return cb();
437-
const txs = _.map(result, tx => {
437+
const txs = result.map(tx => {
438438
return TxProposal.fromObj(tx);
439439
});
440440
return this._completeTxData(walletId, txs, cb);
@@ -473,7 +473,7 @@ export class Storage {
473473
.toArray((err, result) => {
474474
if (err) return cb(err);
475475
if (!result) return cb();
476-
const txs = _.map(result, tx => {
476+
const txs = result.map(tx => {
477477
return TxProposal.fromObj(tx);
478478
});
479479
return this._completeTxData(walletId, txs, cb);
@@ -517,7 +517,7 @@ export class Storage {
517517
.toArray((err, result) => {
518518
if (err) return cb(err);
519519
if (!result) return cb();
520-
const txs = _.map(result, tx => {
520+
const txs = result.map(tx => {
521521
return TxProposal.fromObj(tx);
522522
});
523523
return this._completeTxData(walletId, txs, cb);
@@ -554,7 +554,7 @@ export class Storage {
554554
.toArray((err, result) => {
555555
if (err) return cb(err);
556556
if (!result) return cb();
557-
const notifications = _.map(result, notification => {
557+
const notifications = result.map(notification => {
558558
return Notification.fromObj(notification);
559559
});
560560
return cb(null, notifications);
@@ -873,7 +873,7 @@ export class Storage {
873873
}
874874
if (!result) return cb();
875875

876-
const preferences = _.map([].concat(result), r => {
876+
const preferences = [].concat(result).map(r => {
877877
return Preferences.fromObj(r);
878878
});
879879
if (copayerId) {
@@ -923,7 +923,7 @@ export class Storage {
923923
if (err) return cb(err);
924924
if (!result || _.isEmpty(result)) return cb(null, []);
925925

926-
const emails = _.map(result, x => {
926+
const emails = result.map(x => {
927927
return Email.fromObj(x);
928928
});
929929

@@ -1322,7 +1322,7 @@ export class Storage {
13221322
.toArray((err, result) => {
13231323
if (err) return cb(err);
13241324
const notes = _.compact(
1325-
_.map(result, note => {
1325+
result.map(note => {
13261326
return TxNote.fromObj(note);
13271327
})
13281328
);
@@ -1382,7 +1382,7 @@ export class Storage {
13821382

13831383
if (!result) return cb();
13841384

1385-
const tokens = _.map([].concat(result), r => {
1385+
const tokens = [].concat(result).map(r => {
13861386
return PushNotificationSub.fromObj(r);
13871387
});
13881388
return cb(null, tokens);
@@ -1404,7 +1404,7 @@ export class Storage {
14041404

14051405
if (!result) return cb();
14061406

1407-
const tokens = _.map([].concat(result), r => {
1407+
const tokens = [].concat(result).map(r => {
14081408
return PushNotificationSub.fromObj(r);
14091409
});
14101410
return cb(null, tokens);

0 commit comments

Comments
 (0)