Socket
Socket
Sign inDemoInstall

bn.js

Package Overview
Dependencies
0
Maintainers
1
Versions
119
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.5.1 to 4.5.2

2

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

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

@@ -69,3 +69,3 @@ # <img src="./logo.png" alt="bn.js" width="160" height="160" />

* `a.isZero()` - no comments
* `a.cmp(b)` - compare numbers and return `-1` (`<`), `0` (`==`), or `1` (`>`)
* `a.cmp(b)` - compare numbers and return `-1` (a `<` b), `0` (a `==` b), or `1` (a `>` b)
depending on the comparison result (`ucmp`, `cmpn`)

@@ -72,0 +72,0 @@

@@ -170,2 +170,34 @@ var assert = require('assert');

});
describe('.cmpn', function() {
it('should return -1, 0, 1 correctly', function() {
assert.equal(new BN(42).cmpn(42), 0);
assert.equal(new BN(42).cmpn(43), -1);
assert.equal(new BN(42).cmpn(41), 1);
assert.equal(new BN(0x3fffffe).cmpn(0x3fffffe), 0);
assert.equal(new BN(0x3fffffe).cmpn(0x3ffffff), -1);
assert.equal(new BN(0x3fffffe).cmpn(0x3fffffd), 1);
assert.throws(function() {
new BN(0x3fffffe).cmpn(0x4000000);
});
assert.equal(new BN(42).cmpn(-42), 1);
assert.equal(new BN(-42).cmpn(42), -1);
assert.equal(new BN(-42).cmpn(-42), 0);
});
});
describe('.cmp', function() {
it('should return -1, 0, 1 correctly', function() {
assert.equal(new BN(42).cmp(new BN(42)), 0);
assert.equal(new BN(42).cmp(new BN(43)), -1);
assert.equal(new BN(42).cmp(new BN(41)), 1);
assert.equal(new BN(0x3fffffe).cmp(new BN(0x3fffffe)), 0);
assert.equal(new BN(0x3fffffe).cmp(new BN(0x3ffffff)), -1);
assert.equal(new BN(0x3fffffe).cmp(new BN(0x3fffffd)), 1);
assert.equal(new BN(0x3fffffe).cmp(new BN(0x4000000)), -1);
assert.equal(new BN(42).cmp(new BN(-42)), 1);
assert.equal(new BN(-42).cmp(new BN(42)), -1);
assert.equal(new BN(-42).cmp(new BN(-42)), 0);
});
});
});

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc