use [].reverse over prototype

This commit is contained in:
Daniel Cousens 2015-09-27 23:36:31 +10:00
parent 5c1c4589c0
commit 0b4c67406f
6 changed files with 7 additions and 8 deletions

View file

@ -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 () {

View file

@ -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 () {

View file

@ -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) {

View file

@ -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')

View file

@ -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) {

View file

@ -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))
})