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 3.0.6 to 4.0.0

1

index.d.ts

@@ -16,2 +16,3 @@ type IPv4Address = string;

normalize(cidr: Network): Network;
contains(networkA: Network, networkB: Network): boolean;
}

@@ -18,0 +19,0 @@

@@ -64,3 +64,4 @@ "use strict";

function doNetsOverlap(a, b) {
// utility function that returns boundaries of two networks
function getBoundaries(a, b) {
const aStart = a.start({type: "bigInteger"});

@@ -70,3 +71,9 @@ const bStart = b.start({type: "bigInteger"});

const bEnd = b.end({type: "bigInteger"});
return {aStart, bStart, aEnd, bEnd};
}
// returns whether networks fully or partially overlap
function doNetsOverlap(a, b) {
const {aStart, bStart, aEnd, bEnd} = getBoundaries(a, b);
// aaa

@@ -83,8 +90,20 @@ // bbb

// returns whether network a fully contains network b;
function contains(a, b) {
const {aStart, bStart, aEnd, bEnd} = getBoundaries(a, b);
// aaa
// bbbb
if (bStart.compareTo(aStart) < 0) return false; // a starts after b
// aaa
// bbbb
if (bEnd.compareTo(aEnd) > 0) return false; // b starts after a
return true;
}
// exclude b from a and return remainder cidrs
function excludeNets(a, b, v) {
const aStart = a.start({type: "bigInteger"});
const bStart = b.start({type: "bigInteger"});
const aEnd = a.end({type: "bigInteger"});
const bEnd = b.end({type: "bigInteger"});
const {aStart, bStart, aEnd, bEnd} = getBoundaries(a, b);
const parts = [];

@@ -347,2 +366,3 @@

// version mismatch
if (aParsed.address.v4 !== bParsed.address.v4) {

@@ -360,1 +380,13 @@ continue;

};
module.exports.contains = (a, b) => {
const aParsed = parse(a);
const bParsed = parse(b);
// version mismatch
if (aParsed.address.v4 !== bParsed.address.v4) {
return false;
}
return contains(aParsed, bParsed);
};

18

package.json
{
"name": "cidr-tools",
"version": "3.0.6",
"version": "4.0.0",
"author": "silverwind <me@silverwind.io>",

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

"engines": {
"node": ">=10"
"node": ">=12.17.0"
},

@@ -39,12 +39,8 @@ "keywords": [

"devDependencies": {
"eslint": "8.4.1",
"eslint-config-silverwind": "47.1.0",
"jest": "27.4.5",
"updates": "12.2.3",
"versions": "9.1.1"
},
"jest": {
"verbose": false,
"testTimeout": 30000
"eslint": "8.9.0",
"eslint-config-silverwind": "48.1.0",
"jest": "27.5.1",
"updates": "13.0.0",
"versions": "9.2.1"
}
}

@@ -53,2 +53,9 @@ # cidr-tools

### cidrTools.contains(networkA, networkB)
- `networkA` *String*: A CIDR or IP address.
- `networkB` *String*: A CIDR or IP address.
Returns a boolean that indicates whether `networksA` fully contains `networksB`.
### cidrTools.normalize(network)

@@ -55,0 +62,0 @@

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