-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
87 lines (59 loc) · 1.71 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { Address4, Address6 } from 'ip-address';
export interface IpCollectionOptions {
resultFormat?: ResultFormat;
}
export type DefaultResult = string[] | number[];
export interface StatResult {
time: number;
result: DefaultResult;
}
export type IpType = 'v4' | 'v6' | 'unk';
export type ResultFormat = 'default' | 'stat-result';
export interface DataSize {
v4: number;
v6: number;
}
export interface Interval {
start: bigint;
end: bigint;
}
export class IntervalNode {
constructor(interval: Interval, value: any);
interval: Interval;
value: any;
maxEnd: bigint;
left: IntervalNode | null;
right: IntervalNode | null;
intervals: Interval[];
}
export class IntervalMultiTree {
root: IntervalNode | null;
insert(start: string | number | bigint, end: string | number | bigint, value: any): void;
search(ip: string | number | bigint): any[];
}
export interface DataCollection {
[key: string]: IntervalMultiTree;
}
export default class IpCollection {
resultFormat?: ResultFormat;
dataV4?: DataCollection;
dataV6?: DataCollection;
get size(): DataSize;
get height(): DataSize;
constructor(options?: IpCollectionOptions);
lookup(ip: string, all: boolean): any[];
castIpV6ToNum(ip: string): string;
castIpV4ToNum(ip: string): string;
castBigIntIpToV4Str(val: bigint): string;
castBigIntIpToV6Str(val: bigint): string;
formatIP(ip: string): string;
insertRange(start: string, end: string, ipType: IpType, value: string | number): void;
insertRangeAddress(
startAddr: Address6 | Address4,
endAddr: Address6 | Address4,
ipType: IpType,
value: any
): void;
loadFromString(listString: string, value: string | number): void;
clear(): void;
}