ip-utilties 1.4.8 → 1.4.10

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": "1.4.8",
3
+ "version": "1.4.10",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -41,14 +41,14 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "ava": "^6.4.1",
44
- "browser-ava": "^2.3.31",
44
+ "browser-ava": "^2.3.43",
45
45
  "c8": "^10.1.3",
46
46
  "documentation": "^14.0.3",
47
- "semantic-release": "^24.2.7",
48
- "typescript": "^5.9.2"
47
+ "semantic-release": "^25.0.1",
48
+ "typescript": "^5.9.3"
49
49
  },
50
50
  "engines": {
51
- "node": ">=22.19.0"
51
+ "node": ">=22.21.0"
52
52
  },
53
53
  "repository": {
54
54
  "type": "git",
package/src/ip.mjs CHANGED
@@ -32,15 +32,30 @@ const ipv6 = {
32
32
  base: 16
33
33
  };
34
34
 
35
+ /**
36
+ * Encode ipv4 or ipv6 address into number array.
37
+ * @param {string|number[]} address
38
+ * @returns number[]
39
+ */
35
40
  export function encodeIP(address) {
36
41
  const d = _family(address);
37
42
  return d && _encode(d, address);
38
43
  }
39
44
 
45
+ /**
46
+ * Encode ipv6 address into number array.
47
+ * @param {string|number[]|bigint} address
48
+ * @returns number[]
49
+ */
40
50
  export function encodeIPv6(address) {
41
51
  return _encode(ipv6, address);
42
52
  }
43
53
 
54
+ /**
55
+ * Encode ipv6 address into number array.
56
+ * @param {string|number[]|bigint} address
57
+ * @returns number[]
58
+ */
44
59
  export function encodeIPv4(address) {
45
60
  return _encode(ipv4, address);
46
61
  }
@@ -229,7 +244,7 @@ export function normalizeCIDR(address) {
229
244
  prefix = _decode(ipv6, n, prefixLength);
230
245
  if (!prefix.endsWith("::")) {
231
246
  // TODO
232
- prefix += "::";
247
+ prefix += prefix.endsWith(":") ? ":" : "::";
233
248
  }
234
249
  longPrefix = prefix;
235
250
  } else {
package/types/ip.d.mts CHANGED
@@ -1,6 +1,21 @@
1
- export function encodeIP(address: any): any;
2
- export function encodeIPv6(address: any): any;
3
- export function encodeIPv4(address: any): any;
1
+ /**
2
+ * Encode ipv4 or ipv6 address into number array.
3
+ * @param {string|number[]} address
4
+ * @returns number[]
5
+ */
6
+ export function encodeIP(address: string | number[]): any;
7
+ /**
8
+ * Encode ipv6 address into number array.
9
+ * @param {string|number[]|bigint} address
10
+ * @returns number[]
11
+ */
12
+ export function encodeIPv6(address: string | number[] | bigint): any;
13
+ /**
14
+ * Encode ipv6 address into number array.
15
+ * @param {string|number[]|bigint} address
16
+ * @returns number[]
17
+ */
18
+ export function encodeIPv4(address: string | number[] | bigint): any;
4
19
  export function decodeIPv6(address: any, length: any): string;
5
20
  export function decodeIPv4(address: any, length: any): string;
6
21
  export function decodeIP(address: any, length: any): string;