cidr-tools
Advanced tools
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" | ||
} | ||
} |
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
15561
1
371
- Removedstring-natural-compare@3.0.1
- Removedstring-natural-compare@3.0.1(transitive)