cidr-tools
Advanced tools
Comparing version 2.0.0 to 2.0.1
13
index.js
@@ -139,9 +139,11 @@ "use strict"; | ||
function biggestPowerOfTwo(num) { | ||
if (num === 0) return 0; | ||
return Math.pow(2, num.toString(2).length - 1); | ||
if (num.compareTo(bigint("0")) === 0) return bigint("0"); | ||
const power = bigint(String(num.toString(2).length - 1)); | ||
return bigint("2").pow(power); | ||
} | ||
function subparts(part) { | ||
const size = bigint(String(diff(part.end, part.start))); | ||
const biggest = bigint(String(biggestPowerOfTwo(Number(size.toString())))); | ||
const size = bigint(diff(part.end, part.start)); | ||
const biggest = biggestPowerOfTwo(size); | ||
if (size.equals(biggest)) return [part]; | ||
@@ -169,3 +171,4 @@ | ||
if (b.constructor.name !== "BigInteger") b = bigint(b); | ||
return Number((a.add(bigint("1"))).subtract(b).toString()); | ||
a = a.add(bigint("1")); | ||
return a.subtract(b).toString(); | ||
} | ||
@@ -172,0 +175,0 @@ |
{ | ||
"name": "cidr-tools", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"author": "silverwind <me@silverwind.io>", | ||
@@ -5,0 +5,0 @@ "description": "Tools to work with IPv4 and IPv6 CIDR network lists", |
@@ -49,4 +49,4 @@ # cidr-tools | ||
- `networkA` *String*: A CIDR or IP addresses. | ||
- `networkB` *String*: A CIDR or IP addresses. | ||
- `networkA` *String*: A CIDR or IP address. | ||
- `networkB` *String*: A CIDR or IP address. | ||
@@ -57,3 +57,3 @@ Returns a boolean that indicates if the networks overlap (intersect) each other. | ||
- `network` *String*: A CIDR or IP addresses. | ||
- `network` *String*: A CIDR or IP address. | ||
@@ -60,0 +60,0 @@ Returns a normalized representation of a IP or CIDR. Will not include a prefix on IPs. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12190
261
1