Skip to content

Commit 3de1e7e

Browse files
committed
adjust code for rules in new semistandard version
1 parent 8e612d9 commit 3de1e7e

10 files changed

Lines changed: 67 additions & 62 deletions

File tree

benchmarks/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable new-cap, no-new */
1+
/* eslint-disable new-cap, no-new */
22

33
var benchmark = require('benchmark');
44
var crypto = require('crypto');
@@ -135,9 +135,9 @@ while (fixtures.length < 25) {
135135
fixture.as4 = fixture.a4.multiply(fixture.a4).add(bigi.valueOf(0x2adbeef));
136136
// fixture.as5 = fixture.a5.mul(fixture.a5).add(0x2adbeef);
137137
fixture.as6 = fixture.a6.multiply(fixture.a6).add(
138-
new BigInteger('2adbeef', 16));
138+
new BigInteger('2adbeef', 16));
139139
fixture.as8 = fixture.a8.multiply(fixture.a8).add(
140-
SilentMattBigInteger.parse('2adbeef', 16));
140+
SilentMattBigInteger.parse('2adbeef', 16));
141141

142142
fixture.am1 = fixture.a1.toRed(bn.red('k256'));
143143
fixture.am5 = new sjcl.prime.p256k(fixture.a5);

lib/bn.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2477,7 +2477,7 @@
24772477
var cmp = mod.cmp(half);
24782478

24792479
// Round down
2480-
if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
2480+
if (cmp < 0 || (r2 === 1 && cmp === 0)) return dm.div;
24812481

24822482
// Round up
24832483
return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);

test/arithmetic-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* global describe, it */
22

3-
var assert = require('assert');
3+
var assert = require('assert').strict;
44
var BN = require('../').BN;
55
var fixtures = require('./fixtures');
66

test/binary-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* global describe, it */
22

3-
var assert = require('assert');
3+
var assert = require('assert').strict;
44
var BN = require('../').BN;
55

66
describe('BN.js/Binary', function () {

test/constructor-test.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* global describe, it */
22

3-
var assert = require('assert');
3+
var assert = require('assert').strict;
44
var BN = require('../').BN;
55

66
describe('BN.js/Constructor', function () {
@@ -99,13 +99,11 @@ describe('BN.js/Constructor', function () {
9999

100100
it('should not accept decimal', function () {
101101
assert.throws(function () {
102-
var res = new BN('10.00', 10);
103-
res;
102+
new BN('10.00', 10); // eslint-disable-line no-new
104103
}, /Invalid character/);
105104

106105
assert.throws(function () {
107-
var res = new BN('16.00', 16);
108-
res;
106+
new BN('16.00', 16); // eslint-disable-line no-new
109107
}, /Invalid character/);
110108
});
111109

@@ -121,8 +119,7 @@ describe('BN.js/Constructor', function () {
121119
'hexadecimal'
122120
].forEach(function (str) {
123121
assert.throws(function () {
124-
var res = new BN(str, 16);
125-
res;
122+
new BN(str, 16); // eslint-disable-line no-new
126123
}, /Invalid character in /);
127124
});
128125
});

test/pummel/dh-group-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* global describe, it */
22

3-
var assert = require('assert');
3+
var assert = require('assert').strict;
44
var BN = require('../../').BN;
55
var fixtures = require('../fixtures');
66

test/red-test.js

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* global describe, it */
22

3-
var assert = require('assert');
3+
var assert = require('assert').strict;
44
var BN = require('../').BN;
55

66
describe('BN.js/Reduction context', function () {
@@ -170,16 +170,18 @@ describe('BN.js/Reduction context', function () {
170170
assert.equal(p.ireduce(new BN(0xdead)).toString(16), 'dead');
171171
assert.equal(p.ireduce(new BN('deadbeef', 16)).toString(16), 'deadbeef');
172172

173-
var num = new BN('fedcba9876543210fedcba9876543210dead' +
174-
'fedcba9876543210fedcba9876543210dead',
173+
var num = new BN(
174+
'fedcba9876543210fedcba9876543210dead' +
175+
'fedcba9876543210fedcba9876543210dead',
175176
16);
176177
var exp = num.mod(p.p).toString(16);
177178
assert.equal(p.ireduce(num).toString(16), exp);
178179

179-
var regr = new BN('f7e46df64c1815962bf7bc9c56128798' +
180-
'3f4fcef9cb1979573163b477eab93959' +
181-
'335dfb29ef07a4d835d22aa3b6797760' +
182-
'70a8b8f59ba73d56d01a79af9',
180+
var regr = new BN(
181+
'f7e46df64c1815962bf7bc9c56128798' +
182+
'3f4fcef9cb1979573163b477eab93959' +
183+
'335dfb29ef07a4d835d22aa3b6797760' +
184+
'70a8b8f59ba73d56d01a79af9',
183185
16);
184186
exp = regr.mod(p.p).toString(16);
185187

@@ -197,8 +199,9 @@ describe('BN.js/Reduction context', function () {
197199
var p = BN._prime('k256').p;
198200
var red = BN.red('k256');
199201

200-
var n = new BN('9cd8cb48c3281596139f147c1364a3ed' +
201-
'e88d3f310fdb0eb98c924e599ca1b3c9',
202+
var n = new BN(
203+
'9cd8cb48c3281596139f147c1364a3ed' +
204+
'e88d3f310fdb0eb98c924e599ca1b3c9',
202205
16);
203206
var expected = n.sqr().mod(p);
204207
var actual = n.toRed(red).redSqr().fromRed();
@@ -225,25 +228,27 @@ describe('BN.js/Reduction context', function () {
225228
var t = Buffer.from('aff1651e4cd6036d57aa8b2a05ccf1a9d5a40166340ecbbdc55' +
226229
'be10b568aa0aa3d05ce9a2fcec9df8ed018e29683c6051cb83e' +
227230
'46ce31ba4edb045356a8d0d80b', 'hex');
228-
var g = new BN('5c7ff6b06f8f143fe8288433493e4769c4d988ace5be25a0e24809670' +
229-
'716c613d7b0cee6932f8faa7c44d2cb24523da53fbe4f6ec3595892d1' +
230-
'aa58c4328a06c46a15662e7eaa703a1decf8bbb2d05dbe2eb956c142a' +
231-
'338661d10461c0d135472085057f3494309ffa73c611f78b32adbb574' +
232-
'0c361c9f35be90997db2014e2ef5aa61782f52abeb8bd6432c4dd097b' +
233-
'c5423b285dafb60dc364e8161f4a2a35aca3a10b1c4d203cc76a470a3' +
234-
'3afdcbdd92959859abd8b56e1725252d78eac66e71ba9ae3f1dd24871' +
235-
'99874393cd4d832186800654760e1e34c09e4d155179f9ec0dc4473f9' +
236-
'96bdce6eed1cabed8b6f116f7ad9cf505df0f998e34ab27514b0ffe7',
231+
var g = new BN(
232+
'5c7ff6b06f8f143fe8288433493e4769c4d988ace5be25a0e24809670' +
233+
'716c613d7b0cee6932f8faa7c44d2cb24523da53fbe4f6ec3595892d1' +
234+
'aa58c4328a06c46a15662e7eaa703a1decf8bbb2d05dbe2eb956c142a' +
235+
'338661d10461c0d135472085057f3494309ffa73c611f78b32adbb574' +
236+
'0c361c9f35be90997db2014e2ef5aa61782f52abeb8bd6432c4dd097b' +
237+
'c5423b285dafb60dc364e8161f4a2a35aca3a10b1c4d203cc76a470a3' +
238+
'3afdcbdd92959859abd8b56e1725252d78eac66e71ba9ae3f1dd24871' +
239+
'99874393cd4d832186800654760e1e34c09e4d155179f9ec0dc4473f9' +
240+
'96bdce6eed1cabed8b6f116f7ad9cf505df0f998e34ab27514b0ffe7',
237241
16);
238-
var p = new BN('9db6fb5951b66bb6fe1e140f1d2ce5502374161fd6538df1648218642' +
239-
'f0b5c48c8f7a41aadfa187324b87674fa1822b00f1ecf8136943d7c55' +
240-
'757264e5a1a44ffe012e9936e00c1d3e9310b01c7d179805d3058b2a9' +
241-
'f4bb6f9716bfe6117c6b5b3cc4d9be341104ad4a80ad6c94e005f4b99' +
242-
'3e14f091eb51743bf33050c38de235567e1b34c3d6a5c0ceaa1a0f368' +
243-
'213c3d19843d0b4b09dcb9fc72d39c8de41f1bf14d4bb4563ca283716' +
244-
'21cad3324b6a2d392145bebfac748805236f5ca2fe92b871cd8f9c36d' +
245-
'3292b5509ca8caa77a2adfc7bfd77dda6f71125a7456fea153e433256' +
246-
'a2261c6a06ed3693797e7995fad5aabbcfbe3eda2741e375404ae25b',
242+
var p = new BN(
243+
'9db6fb5951b66bb6fe1e140f1d2ce5502374161fd6538df1648218642' +
244+
'f0b5c48c8f7a41aadfa187324b87674fa1822b00f1ecf8136943d7c55' +
245+
'757264e5a1a44ffe012e9936e00c1d3e9310b01c7d179805d3058b2a9' +
246+
'f4bb6f9716bfe6117c6b5b3cc4d9be341104ad4a80ad6c94e005f4b99' +
247+
'3e14f091eb51743bf33050c38de235567e1b34c3d6a5c0ceaa1a0f368' +
248+
'213c3d19843d0b4b09dcb9fc72d39c8de41f1bf14d4bb4563ca283716' +
249+
'21cad3324b6a2d392145bebfac748805236f5ca2fe92b871cd8f9c36d' +
250+
'3292b5509ca8caa77a2adfc7bfd77dda6f71125a7456fea153e433256' +
251+
'a2261c6a06ed3693797e7995fad5aabbcfbe3eda2741e375404ae25b',
247252
16);
248253
var q = new BN('f2c3119374ce76c9356990b465374a17f23f9ed35089bd969f61c6dde' +
249254
'9998c1f', 16);

test/utils-test.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* global describe, it */
22

3-
var assert = require('assert');
3+
var assert = require('assert').strict;
44
var BN = require('../').BN;
55

66
describe('BN.js/Utils', function () {
@@ -299,14 +299,16 @@ describe('BN.js/Utils', function () {
299299
'fffffffffffffffffffffffffffffffe', 16).fromTwos(256).toNumber(), -2);
300300
assert.equal(new BN('ffffffffffffffffffffffffffffffff' +
301301
'ffffffffffffffffffffffffffffffff', 16).fromTwos(256).toNumber(), -1);
302-
assert.equal(new BN('7fffffffffffffffffffffffffffffff' +
302+
assert.equal(
303+
new BN('7fffffffffffffffffffffffffffffff' +
303304
'ffffffffffffffffffffffffffffffff', 16).fromTwos(256).toString(10),
304305
new BN('5789604461865809771178549250434395392663499' +
305-
'2332820282019728792003956564819967', 10).toString(10));
306-
assert.equal(new BN('80000000000000000000000000000000' +
306+
'2332820282019728792003956564819967', 10).toString(10));
307+
assert.equal(
308+
new BN('80000000000000000000000000000000' +
307309
'00000000000000000000000000000000', 16).fromTwos(256).toString(10),
308310
new BN('-578960446186580977117854925043439539266349' +
309-
'92332820282019728792003956564819968', 10).toString(10));
311+
'92332820282019728792003956564819968', 10).toString(10));
310312
});
311313
});
312314

@@ -326,10 +328,12 @@ describe('BN.js/Utils', function () {
326328
'fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe');
327329
assert.equal(new BN('-1', 10).toTwos(256).toString(16),
328330
'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');
329-
assert.equal(new BN('5789604461865809771178549250434395392663' +
331+
assert.equal(
332+
new BN('5789604461865809771178549250434395392663' +
330333
'4992332820282019728792003956564819967', 10).toTwos(256).toString(16),
331334
'7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');
332-
assert.equal(new BN('-578960446186580977117854925043439539266' +
335+
assert.equal(
336+
new BN('-578960446186580977117854925043439539266' +
333337
'34992332820282019728792003956564819968', 10).toTwos(256).toString(16),
334338
'8000000000000000000000000000000000000000000000000000000000000000');
335339
});

util/genCombMulTo.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function genCombMulTo (alen, blen) {
3030
var minJ = Math.max(0, k - alen + 1);
3131
var maxJ = Math.min(k, blen - 1);
3232

33-
src.push('\/* k = ' + k + ' *\/');
33+
src.push('/* k = ' + k + ' */');
3434
src.push('var w' + k + ' = c;');
3535
src.push('c = 0;');
3636
for (var j = minJ; j <= maxJ; j++) {
@@ -53,11 +53,11 @@ function genCombMulTo (alen, blen) {
5353
for (k = 0; k < len; k++) {
5454
src.push('o[' + k + '] = w' + k + ';');
5555
}
56-
src.push('if (c !== 0) {',
57-
' o[' + k + '] = c;',
58-
' out.length++;',
59-
'}',
60-
'return out;');
56+
src.push('if (c !== 0) {');
57+
src.push(' o[' + k + '] = c;');
58+
src.push(' out.length++;');
59+
src.push('}');
60+
src.push('return out;');
6161

6262
return src.join('\n');
6363
}

util/genCombMulTo10.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@ function genCombMulTo (alen, blen) {
2929
var minJ = Math.max(0, k - alen + 1);
3030
var maxJ = Math.min(k, blen - 1);
3131

32-
src.push('\/* k = ' + k + ' *\/');
32+
src.push('/* k = ' + k + ' */');
3333
src.push('lo = Math.imul(al' + (k - minJ) + ', bl' + minJ + ');');
3434
src.push('mid = Math.imul(al' + (k - minJ) + ', bh' + minJ + ');');
35-
src.push(
36-
'mid = (mid + Math.imul(ah' + (k - minJ) + ', bl' + minJ + ')) | 0;');
35+
src.push('mid = (mid + Math.imul(ah' + (k - minJ) + ', bl' + minJ + ')) | 0;');
3736
src.push('hi = Math.imul(ah' + (k - minJ) + ', bh' + minJ + ');');
3837

3938
for (var j = minJ + 1; j <= maxJ; j++) {
@@ -53,11 +52,11 @@ function genCombMulTo (alen, blen) {
5352
for (k = 0; k < len; k++) {
5453
src.push('o[' + k + '] = w' + k + ';');
5554
}
56-
src.push('if (c !== 0) {',
57-
' o[' + k + '] = c;',
58-
' out.length++;',
59-
'}',
60-
'return out;');
55+
src.push('if (c !== 0) {');
56+
src.push(' o[' + k + '] = c;');
57+
src.push(' out.length++;');
58+
src.push('}');
59+
src.push('return out;');
6160

6261
return src.join('\n');
6362
}

0 commit comments

Comments
 (0)