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 6.4.1 to 6.4.2

2

index.d.ts

@@ -1,3 +0,1 @@

import exp from "constants";
type IPv4Address = string;

@@ -4,0 +2,0 @@ type IPv4CIDR = string;

38

index.js

@@ -7,4 +7,4 @@ import ipRegex from "ip-regex";

const bits = {
"v4": 32,
"v6": 128,
4: 32,
6: 128,
};

@@ -56,3 +56,3 @@

if (version) {
parsed.cidr = `${str}/${bits[`v${version}`]}`;
parsed.cidr = `${str}/${bits[version]}`;
parsed.version = version;

@@ -68,3 +68,3 @@ parsed.single = true;

const {number, version} = parseIp(ip);
const numBits = bits[`v${version}`];
const numBits = bits[version];
const ipBits = number.toString(2).padStart(numBits, "0");

@@ -235,3 +235,3 @@ const prefixLen = Number(numBits - prefix);

number: BigInt(part.start.toString()),
version: Number(v.substring(1)),
version: v,
}));

@@ -244,6 +244,4 @@ const zeroes = diff(part.end, part.start).toString(2);

function mapNets(nets) {
const maps = {v4: {}, v6: {}};
for (const {start, end, version} of nets) {
const v = `v${version}`;
const maps = {4: {}, 6: {}};
for (const {start, end, version: v} of nets) {
if (!maps[v][start]) maps[v][start] = {};

@@ -271,7 +269,7 @@ if (!maps[v][end]) maps[v][end] = {};

const merged = {v4: [], v6: []};
const start = {v4: null, v6: null};
const end = {v4: null, v6: null};
const merged = {4: [], 6: []};
const start = {4: null, 6: null};
const end = {4: null, 6: null};
for (const v of ["v4", "v6"]) {
for (const v of [4, 6]) {
const numbers = Object.keys(maps[v]).sort(naturalCompare);

@@ -307,3 +305,3 @@ let depth = 0;

return [...merged.v4.sort(naturalCompare), ...merged.v6.sort(naturalCompare)];
return [...merged[4].sort(naturalCompare), ...merged[6].sort(naturalCompare)];
}

@@ -318,14 +316,14 @@

const bases = {v4: [], v6: []};
const excls = {v4: [], v6: []};
const bases = {4: [], 6: []};
const excls = {4: [], 6: []};
for (const basenet of basenets) {
bases[`v${isCidr(basenet)}`].push(basenet);
bases[isCidr(basenet)].push(basenet);
}
for (const exclnet of exclnets) {
excls[`v${isCidr(exclnet)}`].push(exclnet);
excls[isCidr(exclnet)].push(exclnet);
}
for (const v of ["v4", "v6"]) {
for (const v of [4, 6]) {
for (const exclcidr of excls[v]) {

@@ -344,3 +342,3 @@ for (const [index, basecidr] of bases[v].entries()) {

return bases.v4.concat(bases.v6);
return bases[4].concat(bases[6]);
}

@@ -347,0 +345,0 @@

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

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

"cidr-regex": "4.0.3",
"ip-bigint": "7.2.1",
"ip-bigint": "7.3.0",
"ip-regex": "5.0.0",

@@ -28,9 +28,10 @@ "string-natural-compare": "3.0.1"

"devDependencies": {
"eslint": "8.42.0",
"eslint-config-silverwind": "73.0.2",
"tsd": "0.28.1",
"updates": "14.1.1",
"versions": "11.0.1",
"vitest": "0.32.0"
"eslint": "8.49.0",
"eslint-config-silverwind": "74.1.4",
"tsd": "0.29.0",
"updates": "15.0.2",
"versions": "11.1.0",
"vitest": "0.34.4",
"vitest-config-silverwind": "3.0.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