Skip to content

Commit 1b440e7

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

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ MultiSigInput.prototype._updateScript = function() {
121121

122122
MultiSigInput.prototype._createSignatures = function() {
123123
return _.map(
124-
_.filter(this.signatures, function(signature) { return !_.isUndefined(signature); }),
124+
this.signatures.filter(signature => !_.isUndefined(signature)),
125125
// Future signature types may need refactor of toDER
126126
function(signature) {
127127
return BufferUtil.concat([
@@ -153,7 +153,7 @@ MultiSigInput.prototype.countSignatures = function() {
153153

154154
MultiSigInput.prototype.publicKeysWithoutSignature = function() {
155155
var self = this;
156-
return _.filter(this.publicKeys, function(publicKey) {
156+
return this.publicKeys.filter(publicKey => {
157157
return !(self.signatures[self.publicKeyIndex[publicKey.toString()]]);
158158
});
159159
};

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ export class BtcChain implements IChain {
597597
{}
598598
);
599599

600-
return _.filter(utxos, utxo => {
600+
return utxos.filter(utxo => {
601601
if (utxo.locked) return false;
602602
if (txp.excludeUnconfirmedUtxos && !txp.replaceTxByFee && !utxo.confirmations) return false;
603603
if (excludeIndex[utxo.txid + ':' + utxo.vout]) return false;
@@ -619,7 +619,7 @@ export class BtcChain implements IChain {
619619
}
620620

621621
// remove utxos not economically worth to send
622-
utxos = _.filter(utxos, utxo => {
622+
utxos = utxos.filter(utxo => {
623623
if (utxo.satoshis <= feePerInput) return false;
624624
return true;
625625
});
@@ -831,7 +831,7 @@ export class BtcChain implements IChain {
831831
next => {
832832
const group = groups[i++];
833833

834-
let candidateUtxos = _.filter(utxos, utxo => {
834+
let candidateUtxos = utxos.filter(utxo => {
835835
return utxo.confirmations >= group;
836836
});
837837

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class DogeChain extends BtcChain implements IChain {
5050
{}
5151
);
5252

53-
return _.filter(utxos, utxo => {
53+
return utxos.filter(utxo => {
5454
if (utxo.locked) return false;
5555
if (utxo.satoshis <= feePerInput) return false;
5656
if (txp.excludeUnconfirmedUtxos && !utxo.confirmations) return false;
@@ -266,7 +266,7 @@ export class DogeChain extends BtcChain implements IChain {
266266
next => {
267267
const group = groups[i++];
268268

269-
const candidateUtxos = _.filter(utxos, utxo => {
269+
const candidateUtxos = utxos.filter(utxo => {
270270
return utxo.confirmations >= group;
271271
});
272272

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ export class TxProposal {
417417
}
418418

419419
getCurrentSignatures() {
420-
const acceptedActions = _.filter(this.actions, a => {
420+
const acceptedActions = this.actions.filter(a => {
421421
return a.type == 'accept';
422422
});
423423

@@ -459,7 +459,7 @@ export class TxProposal {
459459
*/
460460
getApprovers() {
461461
return _.map(
462-
_.filter(this.actions, a => {
462+
this.actions.filter(a => {
463463
return a.type == 'accept';
464464
}),
465465
'copayerId'

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export class TxProposalLegacy {
175175

176176
getApprovers() {
177177
return _.map(
178-
_.filter(this.actions, a => {
178+
this.actions.filter(a => {
179179
return a.type == 'accept';
180180
}),
181181
'copayerId'

packages/bitcore-wallet-service/test/integration/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ helpers.stubHistory = function(nr, bcHeight, txs) {
515515
txs= helpers.createTxsV8(nr,bcHeight, txs);
516516
blockchainExplorer.getTransactions = function(walletId, startBlock, cb) {
517517
startBlock = startBlock || 0;
518-
var page = _.filter(txs, (x) => {
518+
var page = txs.filter(x => {
519519
return x.height >=startBlock || x.height == -1
520520
});
521521
return cb(null, page);

packages/bitcore-wallet/bin/cli-utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ Utils.saveClient = function(args, key, cred, opts, cb) {
224224
};
225225

226226
Utils.findOneTxProposal = function(txps, id) {
227-
var matches = _.filter(txps, function(tx) {
227+
var matches = txps.filter(tx => {
228228
return _.endsWith(Utils.shortID(tx.id), id);
229229
});
230230

@@ -357,7 +357,7 @@ Utils.renderTxProposals = function(txps) {
357357
console.log("* TX Proposals:")
358358

359359
txps.forEach((x) => {
360-
var missingSignatures = x.requiredSignatures - _.filter(Object.values(x.actions), function(a) {
360+
var missingSignatures = x.requiredSignatures - Object.values(x.actions).filter(a => {
361361
return a.type == 'accept';
362362
}).length;
363363
console.log("\t%s [\"%s\" by %s] %s => %s", Utils.shortID(x.id), x.message, x.creatorName, Utils.renderAmount(x.amount), x.outputs[0].toAddress);

0 commit comments

Comments
 (0)