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

ip-address

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ip-address - npm Package Compare versions

Comparing version 4.1.0 to 4.2.0

testy.js

31

lib/ipv6.js

@@ -704,1 +704,32 @@ 'use strict';

};
v6.Address.prototype.toByteArray = function () {
return this.bigInteger().toByteArray();
};
v6.Address.prototype.toUnsignedByteArray = function () {
return this.toByteArray().map(function (b) {
return b & 0xFF;
});
};
v6.Address.fromUnsignedByteArray = function (bytes) {
var BYTE_MAX = new BigInteger('256', 10);
var result = new BigInteger('0', 10);
var multiplier = new BigInteger('1', 10);
for (var i = bytes.length - 1; i >= 0; i--) {
result = result.add(
multiplier.multiply(new BigInteger(bytes[i].toString(10), 10)));
multiplier = multiplier.multiply(BYTE_MAX);
}
return v6.Address.fromBigInteger(result);
};
v6.Address.fromByteArray = function (bytes) {
return this.fromUnsignedByteArray(bytes.map(function (b) {
return b & 0xFF;
}));
};

2

package.json

@@ -10,3 +10,3 @@ {

],
"version": "4.1.0",
"version": "4.2.0",
"author": "Beau Gunderson <beau@beaugunderson.com> (https://beaugunderson.com/)",

@@ -13,0 +13,0 @@ "license": "MIT",

@@ -75,2 +75,16 @@ 'use strict';

it('converts to and from a signed byte array', function () {
var bytes = topic.toByteArray();
var address = v6.Address.fromByteArray(bytes);
address.correctForm().should.equal(topic.correctForm());
});
it('converts to and from an unsigned byte array', function () {
var unsignedBytes = topic.toUnsignedByteArray();
var address = v6.Address.fromUnsignedByteArray(unsignedBytes);
address.correctForm().should.equal(topic.correctForm());
});
it('gets the correct type', function () {

@@ -77,0 +91,0 @@ topic.getType().should.equal('Global unicast');

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