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
119
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 3.0.1 to 3.1.0

15

lib/bn.js

@@ -440,4 +440,5 @@ (function (module, exports) {

BN.prototype.toArray = function toArray(endian) {
BN.prototype.toArray = function toArray(endian, padTo) {
this.strip();
var littleEndian = endian === 'le';
var res = new Array(this.byteLength());

@@ -447,3 +448,3 @@ res[0] = 0;

var q = this.clone();
if (endian !== 'le') {
if (!littleEndian) {
// Assume big-endian

@@ -457,3 +458,2 @@ for (var i = 0; q.cmpn(0) !== 0; i++) {

} else {
// Assume little-endian
for (var i = 0; q.cmpn(0) !== 0; i++) {

@@ -467,2 +467,11 @@ var b = q.andln(0xff);

if (padTo) {
while (res.length < padTo) {
if (littleEndian)
res.push(0);
else
res.unshift(0);
}
}
return res;

@@ -469,0 +478,0 @@ };

2

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

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

@@ -60,2 +60,10 @@ var assert = require('assert');

describe('.toArray()', function() {
it('should zero pad to desired lengths', function() {
var n = new BN(0x123456);
assert.deepEqual(n.toArray('be', 5), [ 0x00, 0x00, 0x12, 0x34, 0x56 ]);
assert.deepEqual(n.toArray('le', 5), [ 0x56, 0x34, 0x12, 0x00, 0x00 ]);
});
});
describe('.zeroBits()', function() {

@@ -62,0 +70,0 @@ it('should return proper zeroBits', 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