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.13.1 to 0.13.2

10

lib/bn.js

@@ -870,2 +870,12 @@ // Utils

BN.prototype.iabs = function iabs() {
this.sign = false;
return this
};
BN.prototype.abs = function abs() {
return this.clone().iabs();
};
BN.prototype._wordDiv = function _wordDiv(num, mode) {

@@ -872,0 +882,0 @@ var shift = this.length - num.length;

2

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

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

@@ -68,2 +68,14 @@ var assert = require('assert');

describe('iaddn', function() {
it('should allow a sign change', function() {
var a = new BN(-100)
assert.equal(a.sign, true)
a.iaddn(200)
assert.equal(a.sign, false)
assert.equal(a.toString(), '100')
})
})
it('should subtract numbers', function() {

@@ -109,2 +121,22 @@ assert.equal(new BN(14).sub(new BN(26)).toString(16), '-c');

describe('isubn', function() {
it('should work for positive numbers', function() {
var a = new BN(-100)
assert.equal(a.sign, true)
a.isubn(200)
assert.equal(a.sign, true)
assert.equal(a.toString(), '-300')
})
it('should not allow a sign change', function() {
var a = new BN(-100)
assert.equal(a.sign, true)
assert.throws(function() {
a.isubn(-200)
}, /Sign change is not supported in isubn/)
})
})
it('should mul numbers', function() {

@@ -240,2 +272,8 @@ assert.equal(new BN(0x1001).mul(new BN(0x1234)).toString(16),

it('should absolute numbers', function() {
assert.equal(new BN(0x1001).abs().toString(), '4097');
assert.equal(new BN(-0x1001).abs().toString(), '4097');
assert.equal(new BN('ffffffff', 16).abs().toString(), '4294967295');
})
it('should modn numbers', function() {

@@ -242,0 +280,0 @@ assert.equal(new BN('10', 16).modn(256).toString(16), '10');

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