-
Notifications
You must be signed in to change notification settings - Fork 18
/
index.d.ts
57 lines (40 loc) · 1.57 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { Address4, Address6 } from "ip-address";
type Address = Address4 | Address6;
declare class IPCIDR {
cidr: string;
address: Address;
addressStart: Address;
addressEnd: Address;
size: BigInt;
constructor(cidr: string);
start<T = IPCIDR.FormatResult>(options?: IPCIDR.FormatOptions): T;
end<T = IPCIDR.FormatResult>(options?: IPCIDR.FormatOptions): T;
toRange<T = IPCIDR.FormatResult>(options?: IPCIDR.FormatOptions): [T, T];
loop<T = IPCIDR.FormatResult, R = any>(fn: (ip: T) => Promise<R>, options: IPCIDR.FormatOptions, results?: IPCIDR.ChunkInfo): Promise<R>[];
getChunkInfo(length: number, options: IPCIDR.FormatOptions): IPCIDR.ChunkInfo;
contains(address: IPCIDR.Address | string | BigInt): boolean;
toString(): string;
toArray(options?: IPCIDR.FormatOptions, results?: IPCIDR.ChunkInfo): string[];
toObject(options?: IPCIDR.FormatOptions): { start: string, end: string };
}
declare namespace IPCIDR {
type Address = Address4 | Address6;
type FormatResult = BigInt | Address | string;
interface FormatOptions {
type?: "bigInteger" | "addressObject",
from?: string | number | BigInt;
to?: string | number | BigInt;
limit?: number | BigInt;
}
interface ChunkInfo {
from: BigInt;
to: BigInt;
limit: BigInt;
length: BigInt;
}
export function formatIP<T = FormatResult>(address: Address, options?: any): T;
export function isValidAddress(address: string): boolean;
export function isValidCIDR(address: string): boolean;
export function createAddress(address: string): Address;
}
export default IPCIDR;