From 0b4c67406ff8dab55357ea867ee94032eab98881 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Sun, 27 Sep 2015 23:36:31 +1000 Subject: [PATCH] use [].reverse over prototype --- src/block.js | 2 +- src/transaction.js | 2 +- src/transaction_builder.js | 3 +-- test/bitcoin.core.js | 4 ++-- test/integration/crypto.js | 2 +- test/transaction_builder.js | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/block.js b/src/block.js index 06a8134..b11dc37 100644 --- a/src/block.js +++ b/src/block.js @@ -70,7 +70,7 @@ Block.prototype.getHash = function () { } Block.prototype.getId = function () { - return Array.prototype.reverse.call(this.getHash()).toString('hex') + return [].reverse.call(this.getHash()).toString('hex') } Block.prototype.getUTCDate = function () { diff --git a/src/transaction.js b/src/transaction.js index 39276c5..3a38c21 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -247,7 +247,7 @@ Transaction.prototype.getHash = function () { Transaction.prototype.getId = function () { // transaction hash's are displayed in reverse order - return Array.prototype.reverse.call(this.getHash()).toString('hex') + return [].reverse.call(this.getHash()).toString('hex') } Transaction.prototype.toBuffer = function () { diff --git a/src/transaction_builder.js b/src/transaction_builder.js index efbb8f8..e0dbc25 100644 --- a/src/transaction_builder.js +++ b/src/transaction_builder.js @@ -172,8 +172,7 @@ TransactionBuilder.prototype.addInput = function (txHash, vout, sequence, prevOu // is it a hex string? if (typeof txHash === 'string') { // transaction hashs's are displayed in reverse order, un-reverse it - txHash = new Buffer(txHash, 'hex') - Array.prototype.reverse.call(txHash) + txHash = [].reverse.call(new Buffer(txHash, 'hex')) // is it a Transaction object? } else if (txHash instanceof Transaction) { diff --git a/test/bitcoin.core.js b/test/bitcoin.core.js index d3f7d26..0833e3d 100644 --- a/test/bitcoin.core.js +++ b/test/bitcoin.core.js @@ -150,7 +150,7 @@ describe('Bitcoin-core', function () { var input = inputs[i] // reverse because test data is reversed - var prevOutHash = Array.prototype.reverse.call(new Buffer(input[0], 'hex')) + var prevOutHash = [].reverse.call(new Buffer(input[0], 'hex')) var prevOutIndex = input[1] assert.deepEqual(txIn.hash, prevOutHash) @@ -203,7 +203,7 @@ describe('Bitcoin-core', function () { var hashType = f[3] // reverse because test data is reversed - var expectedHash = Array.prototype.reverse.call(new Buffer(f[4], 'hex')) + var expectedHash = [].reverse.call(new Buffer(f[4], 'hex')) var hashTypes = [] if ((hashType & 0x1f) === bitcoin.Transaction.SIGHASH_NONE) hashTypes.push('SIGHASH_NONE') diff --git a/test/integration/crypto.js b/test/integration/crypto.js index 8ec74fc..6eff730 100644 --- a/test/integration/crypto.js +++ b/test/integration/crypto.js @@ -134,7 +134,7 @@ describe('bitcoinjs-lib (crypto)', function () { assert(bitcoin.script.isPubKeyHashInput(scriptChunks), 'Expected pubKeyHash script') - var prevOutTxId = Array.prototype.reverse.call(new Buffer(transaction.ins[input.vout].hash)).toString('hex') + var prevOutTxId = [].reverse.call(new Buffer(transaction.ins[input.vout].hash)).toString('hex') var prevVout = transaction.ins[input.vout].index tasks.push(function (callback) { diff --git a/test/transaction_builder.js b/test/transaction_builder.js index de6790e..dc1877a 100644 --- a/test/transaction_builder.js +++ b/test/transaction_builder.js @@ -91,7 +91,7 @@ describe('TransactionBuilder', function () { var tx = new Transaction() f.inputs.forEach(function (input) { - var txHash = Array.prototype.reverse.call(new Buffer(input.txId, 'hex')) + var txHash = [].reverse.call(new Buffer(input.txId, 'hex')) tx.addInput(txHash, input.vout, undefined, bscript.fromASM(input.scriptSig)) })