Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bn.js

Package Overview
Dependencies
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bn.js - npm Package Compare versions

Comparing version 0.14.2 to 0.15.0

5

lib/bn.js

@@ -287,3 +287,3 @@ // Utils

BN.prototype.toString = function toString(base) {
BN.prototype.toString = function toString(base, padding) {
base = base || 10;

@@ -293,2 +293,3 @@ if (base === 16 || base === 'hex') {

var off = 0;
var padding = padding | 0 || 1;
var carry = 0;

@@ -311,2 +312,4 @@ for (var i = 0; i < this.length; i++) {

out = carry.toString(16) + out;
while (out.length % padding !== 0)
out = '0' + out;
if (this.sign)

@@ -313,0 +316,0 @@ out = '-' + out;

2

package.json
{
"name": "bn.js",
"version": "0.14.2",
"version": "0.15.0",
"description": "Big number implementation in pure javascript",

@@ -5,0 +5,0 @@ "main": "lib/bn.js",

@@ -73,2 +73,38 @@ var assert = require('assert');

describe('hex padding', function(){
it('should have length of 8 from leading 15', function(){
var a = new BN('ffb9602', 16);
var b = new Buffer(a.toString('hex', 2), 'hex');
assert.equal(a.toString('hex', 2).length, 8);
});
it('should have length of 8 from leading zero', function(){
var a = new BN('fb9604', 16);
var b = new Buffer(a.toString('hex', 8), 'hex');
assert.equal(a.toString('hex', 8).length, 8);
});
it('should have length of 8 from leading zeros', function(){
var a = new BN(0);
var b = new Buffer(a.toString('hex', 8), 'hex');
assert.equal(a.toString('hex', 8).length, 8);
});
it('should have length of 64 from leading 15', function(){
var a = new BN(
'ffb96ff654e61130ba8422f0debca77a0ea74ae5ea8bca9b54ab64aabf01003',
16);
var b = new Buffer(a.toString('hex', 2), 'hex');
assert.equal(a.toString('hex', 2).length, 64);
});
it('should have length of 64 from leading zero', function(){
var a = new BN(
'fb96ff654e61130ba8422f0debca77a0ea74ae5ea8bca9b54ab64aabf01003',
16);
var b = new Buffer(a.toString('hex', 64), 'hex');
assert.equal(a.toString('hex', 64).length, 64);
});
});
describe('iaddn', function() {

@@ -75,0 +111,0 @@ it('should allow a sign change', function() {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc