-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathindex.d.ts
49 lines (34 loc) · 1.36 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
import { Address4, Address6 } from "ip-address";
import { BigInteger } from "jsbn";
declare class IPCIDR {
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 | BigInteger): boolean;
toString(): string;
toArray(): string[];
toObject(): { start: string, end: string };
}
declare namespace IPCIDR {
type Address = Address4 | Address6;
type FormatResult = BigInteger | Address | string;
interface FormatOptions {
type?: "bigInteger" | "addressObject",
from?: string | number | BigInteger;
to?: string | number | BigInteger;
limit?: number | BigInteger;
}
interface ChunkInfo {
from: BigInteger;
to: BigInteger;
limit: BigInteger;
length: BigInteger;
}
export function formatIP<T = FormatResult>(address: Address, options?: any): T;
export function isValidAddress(address: string): boolean;
export function createAddress(address: string): Address;
}
export = IPCIDR;