ip-utilties 3.7.0 → 3.7.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ip-utilties",
3
- "version": "3.7.0",
3
+ "version": "3.7.2",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -42,17 +42,12 @@
42
42
  },
43
43
  "devDependencies": {
44
44
  "ava": "^8.0.1",
45
- "browser-ava": "^2.3.67",
46
- "c8": "^11.0.0",
45
+ "browser-ava": "^2.3.69",
46
+ "c8": "^12.0.0",
47
47
  "documentation": "^14.0.3",
48
- "semantic-release": "^25.0.7",
48
+ "semantic-release": "^25.0.8",
49
49
  "typescript": "^7.0.2"
50
50
  },
51
- "overrides": {
52
- "c8": {
53
- "yargs": "^18.0.0"
54
- }
55
- },
56
51
  "engines": {
57
52
  "node": ">=26.4.0"
58
53
  },
package/src/ip.mjs CHANGED
@@ -219,6 +219,12 @@ function _is(family, address) {
219
219
  return (
220
220
  address instanceof family.factory && address.length === family.segments
221
221
  );
222
+
223
+ case "bigint": {
224
+ if (family === ipv6 && address > 1n << BigInt(ipv4.bitLength)) {
225
+ return true;
226
+ }
227
+ }
222
228
  }
223
229
 
224
230
  return false;
@@ -292,8 +298,8 @@ export function normalizeCIDR(address) {
292
298
  let encoded = _encode(family, prefix);
293
299
  const wns = _wellKnownSubnet(family, encoded);
294
300
 
295
- if (wns && !prefixLength) {
296
- prefixLength = wns[2];
301
+ if (wns) {
302
+ prefixLength ||= wns[2];
297
303
  prefix = _decode(
298
304
  family,
299
305
  _prefix(family, encoded, prefixLength),
@@ -301,31 +307,17 @@ export function normalizeCIDR(address) {
301
307
  );
302
308
  longPrefix = _decode(family, wns[0]);
303
309
  } else {
304
- if (_isUniqueLocal(encoded) || _isLinkLocal(family, encoded)) {
305
- prefixLength = family.wellKnownAddresses[0][1]; // TODO
306
- const n = _prefix(family, address, prefixLength);
307
- prefix = _decode(family, n, prefixLength);
308
-
309
- if (family === ipv6) {
310
- if (!prefix.endsWith("::")) {
311
- // TODO
312
- prefix += prefix.endsWith(":") ? ":" : "::";
313
- }
314
- }
315
- longPrefix = prefix;
310
+ prefixLength = prefixLength === undefined ? 0 : parseInt(prefixLength);
311
+
312
+ if (prefixLength) {
313
+ encoded = _prefix(family, prefix, prefixLength);
316
314
  } else {
317
- prefixLength = prefixLength === undefined ? 0 : parseInt(prefixLength);
318
-
319
- if (prefixLength) {
320
- encoded = _prefix(family, prefix, prefixLength);
321
- } else {
322
- if (_isLocalhost(family, encoded)) {
323
- prefixLength = family.localHostPrefixLenth;
324
- }
315
+ if (_isLocalhost(family, encoded)) {
316
+ prefixLength = family.localHostPrefixLenth;
325
317
  }
326
- prefix = _decode(family, encoded, prefixLength);
327
- longPrefix = _decode(family, encoded);
328
318
  }
319
+ prefix = _decode(family, encoded, prefixLength);
320
+ longPrefix = _decode(family, encoded);
329
321
  }
330
322
 
331
323
  return {
package/types/ip.d.mts CHANGED
@@ -41,7 +41,7 @@ export declare function prefixOnlyIP(address: any, length: any): string;
41
41
  export declare function rangeIP(address: any, prefix: any, lowerAdd?: number, upperReduce?: number): any[];
42
42
  export declare function matchPrefixIP(prefix: any, length: any, address: any): boolean;
43
43
  export declare function normalizeCIDR(address: any): {
44
- longPrefix: any;
44
+ longPrefix: string;
45
45
  prefix: any;
46
46
  prefixLength: any;
47
47
  cidr: string;