ip-utilties 3.5.2 → 3.6.0

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.5.2",
3
+ "version": "3.6.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -44,7 +44,7 @@
44
44
  "browser-ava": "^2.3.66",
45
45
  "c8": "^11.0.0",
46
46
  "documentation": "^14.0.3",
47
- "semantic-release": "^25.0.5",
47
+ "semantic-release": "^25.0.6",
48
48
  "typescript": "^7.0.2"
49
49
  },
50
50
  "overrides": {
package/src/ip.mjs CHANGED
@@ -26,17 +26,19 @@ const ipv4 = {
26
26
  // https://www.geeksforgeeks.org/computer-networks/subnet-cheat-sheet/
27
27
  wellKnownAddresses: [
28
28
  [new Uint8Array([0, 0, 0, 0]), 8], // This network
29
- [new Uint8Array([10, 0, 0, 0]), 8], // Private Address Block
30
- [new Uint8Array([100, 64, 0, 0]), 10], // Carrier-grade NAT
29
+ [new Uint8Array([10, 0, 0, 0]), 8], // Private network (RFC 1918)
30
+ [new Uint8Array([100, 64, 0, 0]), 10], // Carrier-grade NAT / Shared address space (CGN)
31
31
  [new Uint8Array([127, 0, 0, 0]), 8], // Loopback
32
32
  [new Uint8Array([127, 0, 53, 53]), 0], // Name collision occurrence
33
- [new Uint8Array([169, 254, 0, 0]), 16], // Link local
34
- [new Uint8Array([172, 16, 0, 0]), 12], // Private Address Block
33
+ [new Uint8Array([169, 254, 0, 0]), 16], // Link-local address (Autoconfiguration)
34
+ [new Uint8Array([172, 16, 0, 0]), 12], // Private network (RFC 1918)
35
35
  [new Uint8Array([192, 0, 0, 0]), 24], // IETF protocol assignments
36
36
  [new Uint8Array([192, 0, 2, 0]), 24], // TEST-NET-1
37
- [new Uint8Array([192, 168, 0, 0]), 16], // Private Address Block
37
+ [new Uint8Array([192, 168, 0, 0]), 16], // Private network (RFC 1918)
38
38
  [new Uint8Array([198, 18, 0, 0]), 15], // Network benchmark testing
39
39
  [new Uint8Array([198, 51, 100, 0]), 24], // TEST-NET-2
40
+ [new Uint8Array([203, 0, 113, 0]), 24], // Reserved address space used for documentation
41
+ [new Uint8Array([240, 0, 0, 0]), 4], // Reserved for future use or experimental purposes
40
42
  [new Uint8Array([255, 255, 255, 255]), 0] // Limited Broadcast address
41
43
  ]
42
44
  };
@@ -248,6 +250,11 @@ export function prefixIP(address, length) {
248
250
  return _decode(family, _prefix(family, address, length));
249
251
  }
250
252
 
253
+ export function prefixOnlyIP(address, length) {
254
+ const family = _family(address);
255
+ return _decode(family, _prefix(family, address, length), length);
256
+ }
257
+
251
258
  function _prefix(family, address, length) {
252
259
  return (
253
260
  _asBigInt(family, address) & (-1n << BigInt(family.bitLength - length))
package/types/ip.d.mts CHANGED
@@ -37,6 +37,7 @@ export declare function isIPv6(address: any): boolean;
37
37
  export declare function familyIP(address: string | Uint8Array | Uint16Array): string | undefined;
38
38
  export declare function asBigInt(address: any): any;
39
39
  export declare function prefixIP(address: any, length: any): string;
40
+ export declare function prefixOnlyIP(address: any, length: any): string;
40
41
  export declare function rangeIP(address: any, prefix: any, lowerAdd?: number, upperReduce?: number): any[];
41
42
  export declare function matchPrefixIP(prefix: any, length: any, address: any): boolean;
42
43
  export declare function normalizeCIDR(address: any): {