1
- /// <reference types="node" />
2
-
3
- declare interface NetOptions {
4
- family : 'ipv4' | 'ipv6' ;
1
+ declare type NetOptions = {
2
+ family : "ipv4" | "ipv6" ;
5
3
host : string ;
6
- transport : string ;
4
+ transport : "tcp" | "udp" ;
7
5
port : number ;
8
- }
6
+ } ;
9
7
10
- declare interface Protocol {
8
+ declare type Protocol = {
11
9
code : number ;
12
10
size : number ;
13
11
name : string ;
14
- resolvable : boolean ;
15
- path : boolean ;
16
- }
12
+ resolvable : boolean | undefined ;
13
+ path : boolean | undefined ;
14
+ } ;
17
15
18
16
declare interface Protocols {
19
- table : [ number , number , string , boolean ?, boolean ?] [ ] ;
20
- names : Record < string , Protocol > ;
21
- codes : Record < number , Protocol > ;
22
- object ( code : number , size : number , name : string , resolvable ?: any , path ?: any ) : Protocol ;
17
+ table : {
18
+ [ index : number ] : Protocol ;
19
+ } ;
20
+ names : {
21
+ [ index : string ] : Protocol ;
22
+ } ;
23
+ codes : {
24
+ [ index : number ] : Protocol ;
25
+ } ;
26
+ object (
27
+ code : number ,
28
+ size : number ,
29
+ name : string ,
30
+ resolvable ?: any ,
31
+ path ?: any
32
+ ) : Protocol ;
23
33
}
24
34
25
- declare interface NodeAddress {
26
- family : 4 | 6 ;
35
+ declare type NodeAddress = {
36
+ family : "IPv4" | "IPv6" ;
27
37
address : string ;
28
- port : number ;
29
- }
38
+ port : string ;
39
+ } ;
30
40
31
- declare type MultiaddrInput = string | Buffer | Multiaddr ;
41
+ declare type MultiaddrInput = string | Buffer | Multiaddr | null ;
32
42
33
43
declare class Multiaddr {
34
44
/**
@@ -40,6 +50,8 @@ declare class Multiaddr {
40
50
*/
41
51
constructor ( addr ?: MultiaddrInput ) ;
42
52
53
+ buffer : Buffer ;
54
+
43
55
/**
44
56
* Returns Multiaddr as a String
45
57
*/
@@ -142,20 +154,11 @@ declare class Multiaddr {
142
154
isThinWaistAddress ( addr ?: Multiaddr ) : boolean ;
143
155
}
144
156
145
- declare interface MultiaddrClass {
146
- /**
147
- * Creates a [multiaddr](https://github.com/multiformats/multiaddr) from
148
- * a Buffer, String or another Multiaddr instance
149
- * public key.
150
- * @param addr - If String or Buffer, needs to adhere
151
- * to the address format of a [multiaddr](https://github.com/multiformats/multiaddr#string-format)
152
- */
153
- ( addr ?: MultiaddrInput ) : Multiaddr ;
154
-
157
+ declare namespace Multiaddr {
155
158
/**
156
159
* Creates a Multiaddr from a node-friendly address object
157
160
*/
158
- fromNodeAddress ( addr : NodeAddress , transport : string ) : Multiaddr ;
161
+ function fromNodeAddress ( addr : NodeAddress , transport : string ) : Multiaddr ;
159
162
160
163
/**
161
164
* Object containing table, names and codes of all supported protocols.
@@ -164,22 +167,31 @@ declare interface MultiaddrClass {
164
167
* [`.protoCodes()`](#multiaddrprotocodes) or
165
168
* [`.protoNames()`](#multiaddrprotonames)
166
169
*/
167
- protocols : Protocols ;
170
+ const protocols : Protocols ;
168
171
169
172
/**
170
173
* Returns if something is a Multiaddr
171
174
*/
172
- isMultiaddr ( addr : unknown ) : addr is Multiaddr ;
175
+ function isMultiaddr ( addr : unknown ) : addr is Multiaddr ;
173
176
174
177
/**
175
178
* Returns if something is a Multiaddr that is a name
176
179
*/
177
- isName ( addr : Multiaddr ) : boolean ;
180
+ function isName ( addr : Multiaddr ) : boolean ;
178
181
179
182
/**
180
183
* Returns an array of multiaddrs, by resolving the multiaddr that is a name
181
184
*/
182
- resolve ( addr : Multiaddr ) : Promise < Multiaddr [ ] >
185
+ function resolve ( addr : Multiaddr ) : Promise < Multiaddr [ ] > ;
183
186
}
184
187
185
- export = MultiaddrClass ;
188
+ /**
189
+ * Creates a [multiaddr](https://github.com/multiformats/multiaddr) from
190
+ * a Buffer, String or another Multiaddr instance
191
+ * public key.
192
+ * @param addr - If String or Buffer, needs to adhere
193
+ * to the address format of a [multiaddr](https://github.com/multiformats/multiaddr#string-format)
194
+ */
195
+ declare function Multiaddr ( input ?: MultiaddrInput ) : Multiaddr ;
196
+
197
+ export = Multiaddr ;
0 commit comments