-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathican.d.ts
142 lines (128 loc) · 5.03 KB
/
ican.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
interface ICANStatic {
/**
* An object containing all the known ICAN specifications.
*/
countries: Record<ICAN.Specification['countryCode'], ICAN.Specification>;
/**
* Returns the ICAN in an electronic format.
* @param ican The ICAN to convert.
* @returns The ICAN in electronic format.
*/
electronicFormat(ican: string): string;
/**
* Convert the passed BCAN to an ICAN for this country specification.
* @param countryCode The country of the BCAN.
* @param bcan The BCAN to convert to ICAN.
* @returns The ICAN.
*/
fromBCAN(countryCode: string, bcan: string): string;
/**
* Check if the passed ICAN is valid according to this specification.
* @param ican The ICAN to validate.
* @param onlyCrypto Check only crypto definitions. Possible values:
* - `true` = Include all crypto networks.
* - `false` = Exclude crypto networks.
* - `'main' | 'mainnet'` = Mainnets.
* - `'test' | 'testnet'` = Testnets.
* - `'enter' | 'enterprise'` = Enterprise networks.
* @returns True if valid, false otherwise.
*/
isValid(ican: string, onlyCrypto?: boolean | 'main' | 'test' | 'enter' | 'mainnet' | 'testnet' | 'enterprise'): boolean;
/**
* Check if the passed BCAN is valid.
* @param countryCode The country of the BCAN.
* @param bcan The BCAN to validate.
* @param onlyCrypto Check only crypto definitions. Possible values:
* - `true` = Include all crypto networks.
* - `false` = Exclude crypto networks.
* - `'main' | 'mainnet'` = Mainnets.
* - `'test' | 'testnet'` = Testnets.
* - `'enter' | 'enterprise'` = Enterprise networks.
* @returns True if valid, false otherwise.
*/
isValidBCAN(countryCode: string, bcan: string, onlyCrypto?: boolean | 'main' | 'test' | 'enter' | 'mainnet' | 'testnet' | 'enterprise'): boolean;
/**
* Returns the ICAN in a print format.
* @param ican The ICAN to convert.
* @param [separator] The separator to use between ICAN blocks, defaults to ' '.
* @returns The formatted ICAN.
*/
printFormat(ican: string, separator?: string): string;
/**
* Convert the passed ICAN to a country-specific BCAN.
* @param ican The ICAN to convert.
* @param [separator] The separator to use between BCAN blocks, defaults to ' '.
* @returns The BCAN
*/
toBCAN(ican: string, separator?: string): string;
/**
* Returns the ICAN in a short format.
* @param ican The ICAN to convert.
* @param [separator] The separator to use between ICAN openings/endings, defaults to '…'.
* @param [frontCount] The number of characters to show at the beginning, defaults to 4.
* @param [backCount] The number of characters to show at the end, defaults to 4.
* @returns The shortened ICAN.
*/
shortFormat(ican: string, separator?: string, frontCount?: number, backCount?: number): string;
}
declare var ICAN: ICANStatic;
declare namespace ICAN {
interface Specification {
/** The code of the country. */
readonly countryCode: string;
/** The length of the ICAN. */
readonly length: number;
/** The structure of the underlying BCAN (for validation and formatting). */
readonly structure: string;
/**
* The crypto property. Possible values:
* - `true` = All crypto networks.
* - `false` = Non-crypto.
* - `'main' | 'mainnet'` = Mainnets.
* - `'test' | 'testnet'` = Testnets.
* - `'enter' | 'enterprise'` = Enterprise networks.
*/
readonly crypto: boolean | 'main' | 'test' | 'enter' | 'mainnet' | 'testnet' | 'enterprise';
/** An example valid ICAN. */
readonly example: string;
/**
* Check if the passed ICAN is valid according to this specification.
* @param ican The ICAN to validate.
* @param onlyCrypto Check only crypto definitions. Possible values:
* - `true` = Include all crypto networks.
* - `false` = Exclude crypto networks.
* - `'main' | 'mainnet'` = Mainnets.
* - `'test' | 'testnet'` = Testnets.
* - `'enter' | 'enterprise'` = Enterprise networks.
* @returns True if valid, false otherwise.
*/
isValid(ican: string, onlyCrypto?: boolean | 'main' | 'test' | 'enter' | 'mainnet' | 'testnet' | 'enterprise'): boolean;
/**
* Convert the passed ICAN to a country-specific BCAN.
* @param ican The ICAN to convert.
* @param separator The separator to use between BCAN blocks.
* @returns The BCAN.
*/
toBCAN(ican: string, separator: string): string;
/**
* Convert the passed BCAN to an ICAN for this country specification.
* @param bcan The BCAN to convert to ICAN.
* @returns The ICAN.
*/
fromBCAN(bcan: string): string;
/**
* Check if the passed BCAN is valid.
* @param bcan The BCAN to validate.
* @param onlyCrypto Check only crypto definitions. Possible values:
* - `true` = Include all crypto networks.
* - `false` = Exclude crypto networks.
* - `'main' | 'mainnet'` = Mainnets.
* - `'test' | 'testnet'` = Testnets.
* - `'enter' | 'enterprise'` = Enterprise networks.
* @returns True if valid, false otherwise.
*/
isValidBCAN(bcan: string, onlyCrypto?: boolean | 'main' | 'test' | 'enter' | 'mainnet' | 'testnet' | 'enterprise'): boolean;
}
}
export = ICAN;
export as namespace ICAN;