Browse Source

updates lodash to v4

master
matiu 7 years ago
committed by Emilio Almansi
parent
commit
59002ff24d
  1. 2
      lib/encoding/base58.js
  2. 8
      lib/hdprivatekey.js
  3. 4
      lib/hdpublickey.js
  4. 2
      lib/networks.js
  5. 6
      lib/transaction/transaction.js
  6. 2
      package.json
  7. 4
      test/transaction/input/multisig.js
  8. 4
      test/transaction/input/multisigscripthash.js

2
lib/encoding/base58.js

@ -26,7 +26,7 @@ Base58.validCharacters = function validCharacters(chars) {
if (buffer.Buffer.isBuffer(chars)) {
chars = chars.toString();
}
return _.all(_.map(chars, function(char) { return _.contains(ALPHABET, char); }));
return _.every(_.map(chars, function(char) { return _.includes(ALPHABET, char); }));
};
Base58.prototype.set = function(obj) {

8
lib/hdprivatekey.js

@ -74,7 +74,7 @@ function HDPrivateKey(arg) {
HDPrivateKey.isValidPath = function(arg, hardened) {
if (_.isString(arg)) {
var indexes = HDPrivateKey._getDerivationIndexes(arg);
return indexes !== null && _.all(indexes, HDPrivateKey.isValidPath);
return indexes !== null && _.every(indexes, HDPrivateKey.isValidPath);
}
if (_.isNumber(arg)) {
@ -99,11 +99,11 @@ HDPrivateKey._getDerivationIndexes = function(path) {
var steps = path.split('/');
// Special cases:
if (_.contains(HDPrivateKey.RootElementAlias, path)) {
if (_.includes(HDPrivateKey.RootElementAlias, path)) {
return [];
}
if (!_.contains(HDPrivateKey.RootElementAlias, steps[0])) {
if (!_.includes(HDPrivateKey.RootElementAlias, steps[0])) {
return null;
}
@ -123,7 +123,7 @@ HDPrivateKey._getDerivationIndexes = function(path) {
return index;
});
return _.any(indexes, isNaN) ? null : indexes;
return _.some(indexes, isNaN) ? null : indexes;
};
/**

4
lib/hdpublickey.js

@ -75,7 +75,7 @@ function HDPublicKey(arg) {
HDPublicKey.isValidPath = function(arg) {
if (_.isString(arg)) {
var indexes = HDPrivateKey._getDerivationIndexes(arg);
return indexes !== null && _.all(indexes, HDPublicKey.isValidPath);
return indexes !== null && _.every(indexes, HDPublicKey.isValidPath);
}
if (_.isNumber(arg)) {
@ -184,7 +184,7 @@ HDPublicKey.prototype._deriveWithNumber = function(index, hardened) {
HDPublicKey.prototype._deriveFromString = function(path) {
/* jshint maxcomplexity: 8 */
if (_.contains(path, "'")) {
if (_.includes(path, "'")) {
throw new hdErrors.InvalidIndexCantDeriveHardened();
} else if (!HDPublicKey.isValidPath(path)) {
throw new hdErrors.InvalidPath(path);

2
lib/networks.js

@ -38,7 +38,7 @@ function get(arg, keys) {
return networks[index][key] === arg;
};
for (var index in networks) {
if (_.any(keys, containsArg)) {
if (_.some(keys, containsArg)) {
return networks[index];
}
}

6
lib/transaction/transaction.js

@ -541,7 +541,7 @@ Transaction.prototype.from = function(utxo, pubkeys, threshold) {
});
return this;
}
var exists = _.any(this.inputs, function(input) {
var exists = _.some(this.inputs, function(input) {
// TODO: Maybe prevTxId should be a string? Or defined as read only property?
return input.prevTxId.toString('hex') === utxo.txId && input.outputIndex === utxo.outputIndex;
});
@ -647,7 +647,7 @@ Transaction.prototype.uncheckedAddInput = function(input) {
* @return {boolean}
*/
Transaction.prototype.hasAllUtxoInfo = function() {
return _.all(this.inputs.map(function(input) {
return _.every(this.inputs.map(function(input) {
return !!input.output;
}));
};
@ -1103,7 +1103,7 @@ Transaction.prototype.isFullySigned = function() {
);
}
});
return _.all(_.map(this.inputs, function(input) {
return _.every(_.map(this.inputs, function(input) {
return input.isFullySigned();
}));
};

2
package.json

@ -85,7 +85,7 @@
"buffer-compare": "=1.0.0",
"elliptic": "=3.0.3",
"inherits": "=2.0.1",
"lodash": "=3.10.1"
"lodash": "^4.17.4"
},
"devDependencies": {
"bitcore-build": "bitpay/bitcore-build",

4
test/transaction/input/multisig.js

@ -71,14 +71,14 @@ describe('MultiSigInput', function() {
.to(address, 1000000);
var input = transaction.inputs[0];
_.all(input.publicKeysWithoutSignature(), function(publicKeyMissing) {
_.every(input.publicKeysWithoutSignature(), function(publicKeyMissing) {
var serialized = publicKeyMissing.toString();
return serialized === public1.toString() ||
serialized === public2.toString() ||
serialized === public3.toString();
}).should.equal(true);
transaction.sign(privateKey1);
_.all(input.publicKeysWithoutSignature(), function(publicKeyMissing) {
_.every(input.publicKeysWithoutSignature(), function(publicKeyMissing) {
var serialized = publicKeyMissing.toString();
return serialized === public2.toString() ||
serialized === public3.toString();

4
test/transaction/input/multisigscripthash.js

@ -54,14 +54,14 @@ describe('MultiSigScriptHashInput', function() {
.to(address, 1000000);
var input = transaction.inputs[0];
_.all(input.publicKeysWithoutSignature(), function(publicKeyMissing) {
_.every(input.publicKeysWithoutSignature(), function(publicKeyMissing) {
var serialized = publicKeyMissing.toString();
return serialized === public1.toString() ||
serialized === public2.toString() ||
serialized === public3.toString();
}).should.equal(true);
transaction.sign(privateKey1);
_.all(input.publicKeysWithoutSignature(), function(publicKeyMissing) {
_.every(input.publicKeysWithoutSignature(), function(publicKeyMissing) {
var serialized = publicKeyMissing.toString();
return serialized === public2.toString() ||
serialized === public3.toString();

Loading…
Cancel
Save