cidr-tools
Advanced tools
Comparing version 9.0.0 to 9.1.0
@@ -10,2 +10,3 @@ type IPv4Address = string; | ||
cidr: string; | ||
ip: string; | ||
version: number; | ||
@@ -12,0 +13,0 @@ prefix: string; |
20
index.js
@@ -41,4 +41,5 @@ import {parseIp, stringifyIp, normalizeIp, ipVersion} from "ip-bigint"; | ||
let cidr; | ||
if (cidrVer) { | ||
parsed.cidr = str; | ||
cidr = str; | ||
parsed.version = cidrVer; | ||
@@ -48,3 +49,3 @@ } else { | ||
if (version) { | ||
parsed.cidr = `${str}/${bits[version]}`; | ||
cidr = `${str}/${bits[version]}`; | ||
parsed.version = version; | ||
@@ -56,3 +57,3 @@ } else { | ||
const [ip, prefix] = parsed.cidr.split("/"); | ||
const [ipAndMisc, prefix] = cidr.split("/"); | ||
@@ -63,4 +64,7 @@ if (!/^[0-9]+$/.test(prefix)) { | ||
const {number, version, ipv4mapped, scopeid} = parseIp(ipAndMisc); | ||
parsed.ip = stringifyIp({number, version, ipv4mapped, scopeid}); | ||
parsed.cidr = `${parsed.ip}/${prefix}`; | ||
parsed.prefix = prefix; | ||
const {number, version} = parseIp(ip); | ||
const numBits = bits[version]; | ||
@@ -257,3 +261,3 @@ const ipBits = number.toString(2).padStart(numBits, "0"); | ||
function doMerge(maps, v) { | ||
function doMerge(maps) { | ||
let start = null; | ||
@@ -282,3 +286,3 @@ let end = null; | ||
for (const sub of subparts({start, end})) { | ||
merged.push(formatPart(sub, v)); | ||
merged.push(sub); | ||
} | ||
@@ -290,3 +294,3 @@ start = null; | ||
for (const sub of subparts({start, end})) { | ||
merged.push(formatPart(sub, v)); | ||
merged.push(sub); | ||
} | ||
@@ -305,3 +309,3 @@ } | ||
for (const v of [4, 6]) { | ||
merged[v] = doMerge(maps[v], v); | ||
merged[v] = doMerge(maps[v]).map(part => formatPart(part, v)); | ||
} | ||
@@ -308,0 +312,0 @@ |
{ | ||
"name": "cidr-tools", | ||
"version": "9.0.0", | ||
"version": "9.1.0", | ||
"author": "silverwind <me@silverwind.io>", | ||
@@ -9,5 +9,4 @@ "description": "Tools to work with IPv4 and IPv6 CIDR", | ||
"type": "module", | ||
"exports": "./index.js", | ||
"main": "./index.js", | ||
"types": "./index.d.ts", | ||
"exports": "index.js", | ||
"types": "index.d.ts", | ||
"sideEffects": false, | ||
@@ -18,4 +17,4 @@ "engines": { | ||
"files": [ | ||
"./index.js", | ||
"./index.d.ts" | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
@@ -22,0 +21,0 @@ "dependencies": { |
@@ -64,5 +64,5 @@ # cidr-tools | ||
Returns a string or array (depending on input) with a normalized representation. Will not include a prefix on single IPs. | ||
Returns a string or array (depending on input) with a normalized representation. Will not include a prefix on single IPs. Will set network address to the start of the network. | ||
`opts`: Options `Object` | ||
`opts`: *Object* | ||
- `compress`: Whether to compress the IP. For IPv6, this means the "best representation" all-lowercase shortest possible form. Default: `true`. | ||
@@ -77,4 +77,5 @@ - `hexify`: Whether to convert IPv4-Mapped IPv6 addresses to hex. Default: `false`. | ||
`parsed`: `Object` | ||
`parsed`: *Object* | ||
- `cidr` String: The CIDR of the network. | ||
- `ip` String: The IP address inside the CIDR, including any `%scopeid` if present. | ||
- `version` Number: IP protocol version. Either `4` or `6`. | ||
@@ -81,0 +82,0 @@ - `prefix` String: The network prefix, e.g. `64`. |
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
16935
378
93