Comparing version 0.5.3 to 0.5.4
@@ -315,3 +315,3 @@ try { | ||
var size = opts.size || 1; | ||
var size = opts.size === 'auto' ? Math.ceil(buf.length) : (opts.size || 1); | ||
@@ -380,3 +380,2 @@ if (buf.length % size !== 0) { | ||
; | ||
var size = opts.size || 1; | ||
@@ -388,2 +387,4 @@ var hex = this.toString(16); | ||
var size = opts.size === 'auto' ? Math.ceil(hex.length / 2) : (opts.size || 1); | ||
var len = Math.ceil(hex.length / (2 * size)) * size; | ||
@@ -390,0 +391,0 @@ var buf = new Buffer(len); |
{ | ||
"name" : "bignum", | ||
"version" : "0.5.3", | ||
"version" : "0.5.4", | ||
"description" : "Arbitrary-precision integer arithmetic using OpenSSL", | ||
@@ -5,0 +5,0 @@ "main" : "./index.js", |
@@ -427,2 +427,16 @@ var assert = require('assert'); | ||
exports.endian = function () { | ||
var a = bignum(0x0102030405); | ||
assert.eql(a.toBuffer({ endian: 'big', size: 2 }).toString('hex'), '000102030405'); | ||
assert.eql(a.toBuffer({ endian: 'little', size: 2 }).toString('hex'), '010003020504'); | ||
var b = bignum(0x0102030405); | ||
assert.eql(a.toBuffer({ endian: 'big', size: 'auto' }).toString('hex'), '0102030405'); | ||
assert.eql(a.toBuffer({ endian: 'little', size: 'auto' }).toString('hex'), '0504030201'); | ||
var c = new Buffer("000102030405", 'hex'); | ||
assert.eql(bignum.fromBuffer(c, { endian: 'big', size: 'auto'}).toString(16), "0102030405"); | ||
assert.eql(bignum.fromBuffer(c, { endian: 'little', size: 'auto'}).toString(16), "050403020100"); | ||
} | ||
if (process.argv[1] === __filename) { | ||
@@ -429,0 +443,0 @@ assert.eql = assert.deepEqual; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64236
13
1009