Skip to content

Commit

Permalink
eslint: use prefer-const.
Browse files Browse the repository at this point in the history
  • Loading branch information
chjj committed Aug 1, 2017
1 parent 42fe564 commit 9cc5c39
Show file tree
Hide file tree
Showing 208 changed files with 3,982 additions and 3,978 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
"no-extra-semi": 0,
"handle-callback-err": 0,
"no-buffer-constructor": 2,
"no-tabs": 2
"no-tabs": 2,
"prefer-const": ["error", {
"destructuring": "all",
"ignoreReadBeforeAssign": true
}]
}
}
2 changes: 1 addition & 1 deletion bench/bech32.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const bench = require('./bench');

let i, end, addr;

let addrs = [];
const addrs = [];

end = bench('serialize');
for (i = 0; i < 100000; i++) {
Expand Down
8 changes: 4 additions & 4 deletions bench/bench.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';

module.exports = function bench(name) {
let start = process.hrtime();
const start = process.hrtime();
return function end(ops) {
let elapsed = process.hrtime(start);
let time = elapsed[0] + elapsed[1] / 1e9;
let rate = ops / time;
const elapsed = process.hrtime(start);
const time = elapsed[0] + elapsed[1] / 1e9;
const rate = ops / time;

console.log('%s: ops=%d, time=%d, rate=%s',
name, ops, time, rate.toFixed(5));
Expand Down
2 changes: 1 addition & 1 deletion bench/coins.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const TX = require('../lib/primitives/tx');
const bench = require('./bench');

let raw = fs.readFileSync(`${__dirname}/../test/data/wtx.hex`, 'utf8');
let wtx = TX.fromRaw(raw.trim(), 'hex');
const wtx = TX.fromRaw(raw.trim(), 'hex');
let coins = Coins.fromTX(wtx, 1);
let i, j, end, hash;

Expand Down
4 changes: 2 additions & 2 deletions bench/merkle.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ for (let i = 0; i < 3000; i++)
leaves.push(random.randomBytes(32));

{
let end = bench('tree');
const end = bench('tree');
let i;
for (i = 0; i < 1000; i++) {
let [n, m] = merkle.createTree(leaves.slice());
const [n, m] = merkle.createTree(leaves.slice());
assert(n);
assert(!m);
}
Expand Down
4 changes: 2 additions & 2 deletions bench/mnemonic.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ const bench = require('./bench');
const HD = require('../lib/hd');
const Mnemonic = require('../lib/hd/mnemonic');

let mnemonic = new Mnemonic();
const mnemonic = new Mnemonic();
HD.fromMnemonic(mnemonic);

let phrase = mnemonic.getPhrase();
const phrase = mnemonic.getPhrase();
let i, end;

assert.equal(Mnemonic.fromPhrase(phrase).getPhrase(), phrase);
Expand Down
18 changes: 9 additions & 9 deletions bench/tx.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ const encoding = require('../lib/utils/encoding');
const random = require('../lib/crypto/random');
const bench = require('./bench');

let json = require('../test/data/block300025.json');
let block = Block.fromJSON(json);
let btx = { tx: block.txs[397], view: new CoinView() };
const json = require('../test/data/block300025.json');
const block = Block.fromJSON(json);
const btx = { tx: block.txs[397], view: new CoinView() };

let tx3 = parseTX('../test/data/tx3.hex');
const tx3 = parseTX('../test/data/tx3.hex');
let wtx = fs.readFileSync(`${__dirname}/../test/data/wtx.hex`, 'utf8');
let i, tx, end, flags, input;

Expand All @@ -29,11 +29,11 @@ for (i = 0; i < tx.inputs.length; i++) {
}

function parseTX(file) {
let data = fs.readFileSync(`${__dirname}/${file}`, 'utf8');
let parts = data.trim().split(/\n+/);
const data = fs.readFileSync(`${__dirname}/${file}`, 'utf8');
const parts = data.trim().split(/\n+/);
let raw = parts[0];
let tx = TX.fromRaw(raw.trim(), 'hex');
let view = new CoinView();
const tx = TX.fromRaw(raw.trim(), 'hex');
const view = new CoinView();
let i, prev;

for (i = 1; i < parts.length; i++) {
Expand Down Expand Up @@ -97,7 +97,7 @@ for (i = 0; i < 3000; i++)
end(i * tx3.tx.inputs.length);

end = bench('verify2');
let script = tx3.view.getOutputFor(tx3.tx.inputs[0]).script;
const script = tx3.view.getOutputFor(tx3.tx.inputs[0]).script;
for (i = 0; i < 100000; i++)
tx3.tx.signatureHashV0(0, script, Script.hashType.ALL);
end(i);
Expand Down
2 changes: 1 addition & 1 deletion bench/walletdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Outpoint = require('../lib/primitives/outpoint');
let walletdb;

function dummy() {
let hash = random.randomBytes(32).toString('hex');
const hash = random.randomBytes(32).toString('hex');
return new Outpoint(hash, 0);
}

Expand Down
Loading

0 comments on commit 9cc5c39

Please sign in to comment.