ip-utilties 1.0.0 → 1.0.1
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/README.md +2 -2
- package/package.json +1 -1
- package/src/ip.mjs +4 -4
- package/types/ip.d.mts +0 -3
package/README.md
CHANGED
package/package.json
CHANGED
package/src/ip.mjs
CHANGED
|
@@ -62,7 +62,7 @@ export function encodeIPv4(address) {
|
|
|
62
62
|
return _encode(ipv4, address);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
function _encode(definition, address) {
|
|
66
66
|
switch (typeof address) {
|
|
67
67
|
case "string":
|
|
68
68
|
const res = new definition.factory(definition.segments);
|
|
@@ -167,7 +167,7 @@ function _definition(address) {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
|
|
170
|
+
function _is(definition, address) {
|
|
171
171
|
switch (typeof address) {
|
|
172
172
|
case "string":
|
|
173
173
|
return address.indexOf(definition.separator) >= 0;
|
|
@@ -219,7 +219,7 @@ export function prefixIP(address, length) {
|
|
|
219
219
|
return _decode(definition, _prefix(definition, address, length));
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
|
|
222
|
+
function _prefix(definition, address, length) {
|
|
223
223
|
return (
|
|
224
224
|
_asBigInt(definition, address) &
|
|
225
225
|
(definition.mask << BigInt(definition.bitLength - length))
|
|
@@ -283,7 +283,7 @@ export function normalizeIP(address) {
|
|
|
283
283
|
export function reverseArpa(address) {
|
|
284
284
|
if (isIPv6(address)) {
|
|
285
285
|
const ea = encodeIPv6(address);
|
|
286
|
-
|
|
286
|
+
const result = [];
|
|
287
287
|
for (let i = 0; i < ea.length; i++) {
|
|
288
288
|
const v = ea[i];
|
|
289
289
|
for (let i = 0; i < 4; i++) {
|
package/types/ip.d.mts
CHANGED
|
@@ -3,16 +3,13 @@ export function IPV6(...args: any[]): any;
|
|
|
3
3
|
export function encodeIP(address: any): any;
|
|
4
4
|
export function encodeIPv6(address: any): any;
|
|
5
5
|
export function encodeIPv4(address: any): any;
|
|
6
|
-
export function _encode(definition: any, address: any): any;
|
|
7
6
|
export function decodeIPv6(address: any, length: any): string;
|
|
8
7
|
export function decodeIPv4(address: any, length: any): string;
|
|
9
8
|
export function decodeIP(address: any, length: any): string;
|
|
10
9
|
export function isIPv4(address: any): boolean;
|
|
11
10
|
export function isIPv6(address: any): boolean;
|
|
12
|
-
export function _is(definition: any, address: any): boolean;
|
|
13
11
|
export function asBigInt(address: any): bigint;
|
|
14
12
|
export function prefixIP(address: any, length: any): string;
|
|
15
|
-
export function _prefix(definition: any, address: any, length: any): bigint;
|
|
16
13
|
export function rangeIP(address: any, prefix: any, lowerAdd?: number, upperReduce?: number): any[];
|
|
17
14
|
export function normalizeCIDR(address: any): {
|
|
18
15
|
longPrefix?: undefined;
|