-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.d.ts
79 lines (68 loc) · 2.53 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
export interface WhoisLightServerInfo {
server: string;
query: string | null;
}
export interface WhoisLightOptions {
/**
* The default timeout period in milliseconds.
*
* Default: 5000
*/
timeout?: number;
/**
* The default Whois UDP port.
*
* Default: 43
*/
port?: number;
/**
* Boolean indicating whether or not we want to format the response.
*
* Default: false
*/
format?: boolean;
/**
* The amount of requests that should be preformed in parallel. This is only applicable to bulkLookups.
*
* Default: 100
*/
parellel?: number;
}
export type WhoisLightRawResult = string;
export type WhoisLightFormattedResult = Record<string, string>;
export type WhoisLightLookupResult<T extends WhoisLightOptions> = T['format'] extends true ? WhoisLightFormattedResult : WhoisLightRawResult
export type WhoisLightBulkResult<T> = Record<string, T>
export default class WhoisLight {
/**
* TLD to whois server mapping.
*/
static _nameToServer(name: string): WhoisLightServerInfo | null;
/**
* Formats raw whois response to a formatted response.
*/
static _formatResults(res: WhoisLightRawResult): WhoisLightFormattedResult;
/**
* Performs a whois lookup for the specified domain name. Returning the raw or formatted results depending on options.formatted.
* @param options Optional options parameter.
* @param name Domain name to preform whois lookup on.
* @returns Conditionally raw result or formatted result depending on options.format
*/
static lookup<T extends WhoisLightOptions>(options: T, name: string): Promise<WhoisLightLookupResult<T>>;
/**
* Performs a whois lookup for the specified domain name. Returning the raw whois results.
* @param name Domain name to preform whois lookup on.
*/
static lookup(name: string): Promise<WhoisLightRawResult>;
/**
* Performs a bulk whois lookup for several specified domain names. Returning the raw whois results.
* @param options Optional options parameter.
* @param names Domain names to preform lookup on.
* @returns Conditionally raw result or formatted result depending on options.format
*/
static bulkLookup<T extends WhoisLightOptions>(options: T, names: string[]): Promise<WhoisLightBulkResult<WhoisLightLookupResult<T>>>;
/**
* Performs a bulk whois lookup for several specified domain names. Returning the raw whois results.
* @param names Domain names to preform lookup on.
*/
static bulkLookup(names: string[]): Promise<WhoisLightBulkResult<WhoisLightRawResult>>;
}