cidr-tools 11.3.2 → 11.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,9 +1,5 @@
1
1
  //#region index.d.ts
2
- type IPv4Address = string;
3
- type IPv6Address = string;
4
- type IPv4CIDR = string;
5
- type IPv6CIDR = string;
6
- type Network = IPv4Address | IPv4CIDR | IPv6Address | IPv6CIDR;
2
+ type Network = string;
7
3
  type Networks = Network | Array<Network>;
8
4
  type ValidIpVersion = 4 | 6;
9
5
  type ParsedCidr = {
package/dist/index.js CHANGED
@@ -8,7 +8,6 @@ const bits = {
8
8
  const octetStrings = Array.from({ length: 256 }, (_, i) => String(i));
9
9
  const octetDotStrings = Array.from({ length: 256 }, (_, i) => `${i}.`);
10
10
  const prefixStrings = Array.from({ length: 129 }, (_, i) => `/${i}`);
11
- const prefixNumStrings = Array.from({ length: 129 }, (_, i) => String(i));
12
11
  const cmpV4StartEnd = (a, b) => a.start - b.start || a.end - b.end;
13
12
  const cmpV4Start = (a, b) => a.start - b.start;
14
13
  const cmpV6StartEnd = (a, b) => a.start > b.start ? 1 : a.start < b.start ? -1 : a.end > b.end ? 1 : a.end < b.end ? -1 : 0;
@@ -105,7 +104,7 @@ function parseCidr(str) {
105
104
  if (v4num !== -1) {
106
105
  const prefixNum = prefixPresent ? parsePrefixNum(str, slashIndex) : 32;
107
106
  const ip = formatIPv4Fast(v4num);
108
- const prefix = prefixNumStrings[prefixNum];
107
+ const prefix = String(prefixNum);
109
108
  const hostBits = 32 - prefixNum;
110
109
  let startNum, endNum;
111
110
  if (hostBits >= 32) {
@@ -131,7 +130,7 @@ function parseCidr(str) {
131
130
  const { number, version, ipv4mapped, scopeid } = parseIp(ipPart);
132
131
  if (!version) throw new Error(`Network is not a CIDR or IP: "${str}"`);
133
132
  if (prefixNum === -1) prefixNum = bits[version];
134
- const prefix = prefixNumStrings[prefixNum];
133
+ const prefix = String(prefixNum);
135
134
  const ip = stringifyIp({
136
135
  number,
137
136
  version,
@@ -240,13 +239,7 @@ function subparts4(pStart, pEnd, output) {
240
239
  let biggest = biggestPowerOfTwo4(size);
241
240
  let start;
242
241
  let end;
243
- if (size === biggest && pStart % biggest === 0) {
244
- output.push({
245
- start: pStart,
246
- end: pEnd
247
- });
248
- return;
249
- } else if (pStart % biggest === 0) {
242
+ if (pStart % biggest === 0) {
250
243
  start = pStart;
251
244
  end = start + biggest - 1;
252
245
  } else {
@@ -304,13 +297,7 @@ function subparts6(pStart, pEnd, output) {
304
297
  let biggest = biggestPowerOfTwo(size);
305
298
  let start;
306
299
  let end;
307
- if (size === biggest && (pStart & biggest - 1n) === 0n) {
308
- output.push({
309
- start: pStart,
310
- end: pEnd
311
- });
312
- return;
313
- } else if ((pStart & biggest - 1n) === 0n) {
300
+ if ((pStart & biggest - 1n) === 0n) {
314
301
  start = pStart;
315
302
  end = start + biggest - 1n;
316
303
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cidr-tools",
3
- "version": "11.3.2",
3
+ "version": "11.3.3",
4
4
  "author": "silverwind <me@silverwind.io>",
5
5
  "description": "Tools to work with IPv4 and IPv6 CIDR",
6
6
  "repository": "silverwind/cidr-tools",
@@ -17,22 +17,23 @@
17
17
  "node": ">=18"
18
18
  },
19
19
  "dependencies": {
20
- "ip-bigint": "^8.3.2"
20
+ "ip-bigint": "^8.3.4"
21
21
  },
22
22
  "devDependencies": {
23
- "@types/node": "25.5.0",
24
- "@typescript/native-preview": "7.0.0-dev.20260324.1",
25
- "eslint": "10.1.0",
26
- "eslint-config-silverwind": "127.1.4",
23
+ "@types/node": "25.5.2",
24
+ "@typescript/native-preview": "7.0.0-dev.20260409.1",
25
+ "@vitest/coverage-v8": "4.1.4",
26
+ "eslint": "10.2.0",
27
+ "eslint-config-silverwind": "131.0.2",
27
28
  "jest-extended": "7.0.0",
28
- "tsdown": "0.21.4",
29
- "tsdown-config-silverwind": "2.0.2",
29
+ "tsdown": "0.21.7",
30
+ "tsdown-config-silverwind": "2.0.5",
30
31
  "typescript": "5.9.3",
31
- "typescript-config-silverwind": "16.1.0",
32
- "updates": "17.11.2",
32
+ "typescript-config-silverwind": "17.0.0",
33
+ "updates": "17.14.0",
33
34
  "updates-config-silverwind": "2.0.1",
34
- "versions": "14.2.4",
35
- "vitest": "4.1.1",
36
- "vitest-config-silverwind": "11.0.0"
35
+ "versions": "14.2.7",
36
+ "vitest": "4.1.4",
37
+ "vitest-config-silverwind": "11.1.4"
37
38
  }
38
39
  }