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 7.0.0 to 7.0.1

18

index.js
import {parseIp, stringifyIp, normalizeIp, ipVersion} from "ip-bigint";
import naturalCompare from "string-natural-compare";

@@ -12,2 +11,13 @@ const bits = {

// TODO: pass parsed objects in here
function compare(a, b) {
const {number: aNum, version: aVersion} = parseIp(a.replace(/\/.+/, ""));
const {number: bNum, version: bVersion} = parseIp(b.replace(/\/.+/, ""));
if (aVersion === bVersion) {
return aNum - bNum > 0n ? 1 : aNum - bNum < 0n ? -1 : 0;
} else {
return aVersion > bVersion;
}
}
function doNormalize(cidr, {compress = true, hexify = false} = {}) {

@@ -257,3 +267,3 @@ const {start, prefix, single, version} = parse(cidr);

for (const v of [4, 6]) {
const numbers = Object.keys(maps[v]).sort(naturalCompare);
const numbers = Object.keys(maps[v]);
let depth = 0;

@@ -288,3 +298,3 @@

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

@@ -324,3 +334,3 @@

return bases[4].concat(bases[6]);
return bases[4].concat(bases[6]).sort(compare);
}

@@ -327,0 +337,0 @@

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

@@ -21,14 +21,13 @@ "description": "Tools to work with IPv4 and IPv6 CIDR",

"dependencies": {
"ip-bigint": "7.3.0",
"string-natural-compare": "3.0.1"
"ip-bigint": "7.3.0"
},
"devDependencies": {
"eslint": "8.49.0",
"eslint-config-silverwind": "75.0.6",
"eslint": "8.50.0",
"eslint-config-silverwind": "76.0.2",
"tsd": "0.29.0",
"updates": "15.0.2",
"versions": "11.1.0",
"vitest": "0.34.4",
"vitest": "0.34.5",
"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