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

cidr-tools

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cidr-tools - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

36

index.js

@@ -17,6 +17,8 @@ "use strict";

function bigint(numberstring) {
return new BigInteger(numberstring);
}
const bigint = numberstring => new BigInteger(numberstring);
const zero = bigint("0");
const one = bigint("1");
const two = bigint("2");
function parse(str) {

@@ -62,2 +64,3 @@ if (isCidr(str)) {

// exclude b from a and return remainder cidrs
function exclude(a, b, v) {

@@ -72,7 +75,7 @@ const aStart = a.start({type: "bigInteger"});

// aaa
// bbb
// aaa
// bbb
// aaa
// bbb
if (aEnd.compareTo(bStart) < 0 || aStart.compareTo(bEnd) > 0) {
if (aStart.compareTo(bEnd) > 0 || aEnd.compareTo(bStart) < 0) {
return [a.cidr];

@@ -139,5 +142,5 @@ }

function biggestPowerOfTwo(num) {
if (num.compareTo(bigint("0")) === 0) return bigint("0");
if (num.compareTo(zero) === 0) return zero;
const power = bigint(String(num.toString(2).length - 1));
return bigint("2").pow(power);
return two.pow(power);
}

@@ -151,4 +154,13 @@

const start = part.start.add(biggest).divide(biggest).multiply(biggest);
const end = start.add(biggest).subtract(bigint("1"));
let start, end;
if (part.start.remainder(biggest).equals(zero)) {
// start is matching on the size-defined boundary - ex: 0-12, use 0-8
start = part.start;
end = start.add(biggest).subtract(one);
} else {
// start is not matching on the size-defined boundary - 4-16, use 8-16
start = part.end.divide(biggest).multiply(biggest);
end = start.add(biggest).subtract(one);
}
let parts = [{start, end}];

@@ -158,3 +170,3 @@

if (!start.equals(part.start)) {
parts = parts.concat(subparts({start: part.start, end: start.subtract(bigint("1"))}));
parts = parts.concat(subparts({start: part.start, end: start.subtract(one)}));
}

@@ -164,3 +176,3 @@

if (!end.equals(part.end)) {
parts = parts.concat(subparts({start: part.start, end: start.subtract(bigint("1"))}));
parts = parts.concat(subparts({start: end.add(one), end: part.end}));
}

@@ -167,0 +179,0 @@

{
"name": "cidr-tools",
"version": "2.2.0",
"version": "2.2.1",
"author": "silverwind <me@silverwind.io>",

@@ -31,14 +31,14 @@ "description": "Tools to work with IPv4 and IPv6 CIDR network lists",

"ip-address": "^5.8.9",
"ip-cidr": "^2.0.0",
"ip-cidr": "^2.0.1",
"ipv6-normalize": "^1.0.1",
"is-cidr": "^3.0.0",
"jsbn": "^1.1.0",
"string-natural-compare": "^2.0.2"
"string-natural-compare": "^2.0.3"
},
"devDependencies": {
"eslint": "^5.7.0",
"eslint-config-silverwind": "^2.0.9",
"updates": "^4.5.2",
"ver": "^3.0.0"
"eslint": "^5.9.0",
"eslint-config-silverwind": "^2.0.11",
"updates": "^5.4.3",
"ver": "^3.0.1"
}
}
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