sed -i 's/ var / const /', with const->let fixes

This commit is contained in:
Daniel Cousens 2018-06-25 16:37:45 +10:00
parent 91b8823aa8
commit a5db0a4e44
46 changed files with 776 additions and 769 deletions

View file

@ -38,7 +38,7 @@ function compile (chunks) {
typeforce(types.Array, chunks)
var bufferSize = chunks.reduce(function (accum, chunk) {
const bufferSize = chunks.reduce(function (accum, chunk) {
// data chunk
if (Buffer.isBuffer(chunk)) {
// adhere to BIP62.3, minimal push policy
@ -53,14 +53,14 @@ function compile (chunks) {
return accum + 1
}, 0.0)
var buffer = Buffer.allocUnsafe(bufferSize)
var offset = 0
const buffer = Buffer.allocUnsafe(bufferSize)
let offset = 0
chunks.forEach(function (chunk) {
// data chunk
if (Buffer.isBuffer(chunk)) {
// adhere to BIP62.3, minimal push policy
var opcode = asMinimalOP(chunk)
const opcode = asMinimalOP(chunk)
if (opcode !== undefined) {
buffer.writeUInt8(opcode, offset)
offset += 1
@ -88,15 +88,15 @@ function decompile (buffer) {
typeforce(types.Buffer, buffer)
var chunks = []
var i = 0
const chunks = []
let i = 0
while (i < buffer.length) {
var opcode = buffer[i]
const opcode = buffer[i]
// data chunk
if ((opcode > OPS.OP_0) && (opcode <= OPS.OP_PUSHDATA4)) {
var d = pushdata.decode(buffer, i)
const d = pushdata.decode(buffer, i)
// did reading a pushDataInt fail? empty script
if (d === null) return null
@ -105,11 +105,11 @@ function decompile (buffer) {
// attempt to read too much data? empty script
if (i + d.number > buffer.length) return null
var data = buffer.slice(i, i + d.number)
const data = buffer.slice(i, i + d.number)
i += d.number
// decompile minimally
var op = asMinimalOP(data)
const op = asMinimalOP(data)
if (op !== undefined) {
chunks.push(op)
} else {
@ -135,7 +135,7 @@ function toASM (chunks) {
return chunks.map(function (chunk) {
// data?
if (Buffer.isBuffer(chunk)) {
var op = asMinimalOP(chunk)
const op = asMinimalOP(chunk)
if (op === undefined) return chunk.toString('hex')
chunk = op
}
@ -175,7 +175,7 @@ function isCanonicalPubKey (buffer) {
}
function isDefinedHashType (hashType) {
var hashTypeMod = hashType & ~0x80
const hashTypeMod = hashType & ~0x80
// return hashTypeMod > SIGHASH_ALL && hashTypeMod < SIGHASH_SINGLE
return hashTypeMod > 0x00 && hashTypeMod < 0x04