Skip to content

Commit d795fc5

Browse files
committed
Whitespace cleanup.
1 parent 10cb2e6 commit d795fc5

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

bignum.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class AutoBN_CTX
6464
AutoBN_CTX()
6565
{
6666
ctx = BN_CTX_new();
67-
// TODO: Handle ctx == NULL
67+
// TODO: Handle ctx == NULL
6868
}
6969

7070
~AutoBN_CTX()

index.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = BigNum;
99

1010
BigNum.conditionArgs = function(num, base) {
1111
if (typeof num !== 'string') num = num.toString(base || 10);
12-
12+
1313
if (num.match(/e\+/)) { // positive exponent
1414
if (!Number(num).toString().match(/e\+/)) {
1515
return {
@@ -23,7 +23,7 @@ BigNum.conditionArgs = function(num, base) {
2323
.replace(/^0/,'');
2424
var i = n.length - n.indexOf('.');
2525
n = n.replace(/\./,'');
26-
26+
2727
for (; i <= pow; i++) n += '0';
2828
return {
2929
num : n,
@@ -116,7 +116,7 @@ BigNum.prototype.powm = function (num, mod) {
116116
else if (mod instanceof BigNum) {
117117
m = mod;
118118
}
119-
119+
120120
if ((typeof num) === 'number') {
121121
return this.upowm(num, m);
122122
}
@@ -131,14 +131,14 @@ BigNum.prototype.powm = function (num, mod) {
131131

132132
BigNum.prototype.mod = function (num, mod) {
133133
var m, res;
134-
134+
135135
if ((typeof mod) === 'number' || (typeof mod) === 'string') {
136136
m = BigNum(mod);
137137
}
138138
else if (mod instanceof BigNum) {
139139
m = mod;
140140
}
141-
141+
142142
if ((typeof num) === 'number') {
143143
return this.umod(num, m);
144144
}
@@ -307,19 +307,19 @@ BigNum.prototype.nextPrime = function () {
307307

308308
BigNum.fromBuffer = function (buf, opts) {
309309
if (!opts) opts = {};
310-
310+
311311
var endian = { 1 : 'big', '-1' : 'little' }[opts.endian]
312312
|| opts.endian || 'big'
313313
;
314-
314+
315315
var size = opts.size || 1;
316-
316+
317317
if (buf.length % size !== 0) {
318318
throw new RangeError('Buffer length (' + buf.length + ')'
319319
+ ' must be a multiple of size (' + size + ')'
320320
);
321321
}
322-
322+
323323
var hex = [];
324324
for (var i = 0; i < buf.length; i += size) {
325325
var chunk = [];
@@ -328,36 +328,36 @@ BigNum.fromBuffer = function (buf, opts) {
328328
i + (endian === 'big' ? j : (size - j - 1))
329329
]);
330330
}
331-
331+
332332
hex.push(chunk
333333
.map(function (c) {
334334
return (c < 16 ? '0' : '') + c.toString(16);
335335
})
336336
.join('')
337337
);
338338
}
339-
339+
340340
return BigNum(hex.join(''), 16);
341341
};
342342

343343
BigNum.prototype.toBuffer = function (opts) {
344344
if (typeof opts === 'string') {
345345
if (opts !== 'mpint') return 'Unsupported Buffer representation';
346-
346+
347347
var abs = this.abs();
348348
var buf = abs.toBuffer({ size : 1, endian : 'big' });
349349
var len = buf.length === 1 && buf[0] === 0 ? 0 : buf.length;
350350
if (buf[0] & 0x80) len ++;
351-
351+
352352
var ret = new Buffer(4 + len);
353353
if (len > 0) buf.copy(ret, 4 + (buf[0] & 0x80 ? 1 : 0));
354354
if (buf[0] & 0x80) ret[4] = 0;
355-
355+
356356
ret[0] = len & (0xff << 24);
357357
ret[1] = len & (0xff << 16);
358358
ret[2] = len & (0xff << 8);
359359
ret[3] = len & (0xff << 0);
360-
360+
361361
// two's compliment for negative integers:
362362
var isNeg = this.lt(0);
363363
if (isNeg) {
@@ -367,49 +367,49 @@ BigNum.prototype.toBuffer = function (opts) {
367367
}
368368
ret[4] = (ret[4] & 0x7f) | (isNeg ? 0x80 : 0);
369369
if (isNeg) ret[ret.length - 1] ++;
370-
370+
371371
return ret;
372372
}
373-
373+
374374
if (!opts) opts = {};
375-
375+
376376
var endian = { 1 : 'big', '-1' : 'little' }[opts.endian]
377377
|| opts.endian || 'big'
378378
;
379379
var size = opts.size || 1;
380-
380+
381381
var hex = this.toString(16);
382382
if (hex.charAt(0) === '-') throw new Error(
383383
'converting negative numbers to Buffers not supported yet'
384384
);
385-
385+
386386
var len = Math.ceil(hex.length / (2 * size)) * size;
387387
var buf = new Buffer(len);
388-
388+
389389
// zero-pad the hex string so the chunks are all `size` long
390390
while (hex.length < 2 * len) hex = '0' + hex;
391-
391+
392392
var hx = hex
393393
.split(new RegExp('(.{' + (2 * size) + '})'))
394394
.filter(function (s) { return s.length > 0 })
395395
;
396-
396+
397397
hx.forEach(function (chunk, i) {
398398
for (var j = 0; j < size; j++) {
399399
var ix = i * size + (endian === 'big' ? j : size - j - 1);
400400
buf[ix] = parseInt(chunk.slice(j*2,j*2+2), 16);
401401
}
402402
});
403-
403+
404404
return buf;
405405
};
406406

407407
Object.keys(BigNum.prototype).forEach(function (name) {
408408
if (name === 'inspect' || name === 'toString') return;
409-
409+
410410
BigNum[name] = function (num) {
411411
var args = [].slice.call(arguments, 1);
412-
412+
413413
if (num instanceof BigNum) {
414414
return num[name].apply(num, args);
415415
}

0 commit comments

Comments
 (0)