ip-utilties 1.0.5 → 1.1.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 +1 -1
- package/src/ip.mjs +2 -17
- package/types/ip.d.mts +1 -3
package/package.json
CHANGED
package/src/ip.mjs
CHANGED
|
@@ -30,21 +30,6 @@ const ipv6 = {
|
|
|
30
30
|
base: 16
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
export function IPV4(...args) {
|
|
34
|
-
return _create(ipv4, ...args);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function IPV6(...args) {
|
|
38
|
-
return _create(ipv6, ...args);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function _create(definition, ...args) {
|
|
42
|
-
if (args.length === 1) {
|
|
43
|
-
return _encode(definition, args[0]);
|
|
44
|
-
}
|
|
45
|
-
return new definition.factory(args);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
33
|
export function encodeIP(address) {
|
|
49
34
|
const d = _definition(address);
|
|
50
35
|
return d && _encode(d, address);
|
|
@@ -259,8 +244,8 @@ export function normalizeCIDR(address) {
|
|
|
259
244
|
};
|
|
260
245
|
}
|
|
261
246
|
|
|
262
|
-
export function formatCIDR(address,
|
|
263
|
-
return
|
|
247
|
+
export function formatCIDR(address, prefixLength) {
|
|
248
|
+
return prefixLength ? `${decodeIP(address)}/${prefixLength}` : address;
|
|
264
249
|
}
|
|
265
250
|
|
|
266
251
|
export function normalizeIP(address) {
|
package/types/ip.d.mts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export function IPV4(...args: any[]): any;
|
|
2
|
-
export function IPV6(...args: any[]): any;
|
|
3
1
|
export function encodeIP(address: any): any;
|
|
4
2
|
export function encodeIPv6(address: any): any;
|
|
5
3
|
export function encodeIPv4(address: any): any;
|
|
@@ -22,7 +20,7 @@ export function normalizeCIDR(address: any): {
|
|
|
22
20
|
prefixLength: any;
|
|
23
21
|
cidr: string;
|
|
24
22
|
};
|
|
25
|
-
export function formatCIDR(address: any,
|
|
23
|
+
export function formatCIDR(address: any, prefixLength: any): any;
|
|
26
24
|
export function normalizeIP(address: any): string;
|
|
27
25
|
export function reverseArpa(address: any): string;
|
|
28
26
|
export function isLocalhost(address: any): boolean;
|