-
Notifications
You must be signed in to change notification settings - Fork 436
/
index.ts
37 lines (33 loc) · 1016 Bytes
/
index.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
import type { TypedEventTarget } from '../event-target.js'
import type { PeerInfo } from '../peer-info/index.js'
/**
* Any object that implements this Symbol as a property should return a
* PeerDiscovery instance as the property value, similar to how
* `Symbol.Iterable` can be used to return an `Iterable` from an `Iterator`.
*
* @example
*
* ```TypeScript
* import { peerDiscovery, PeerDiscovery } from '@libp2p/peer-discovery'
*
* class MyPeerDiscoverer implements PeerDiscovery {
* get [peerDiscovery] () {
* return this
* }
*
* // ...other methods
* }
* ```
*/
export const peerDiscoverySymbol = Symbol.for('@libp2p/peer-discovery')
/**
* Implementers of this interface can provide a PeerDiscovery implementation to
* interested callers.
*/
export interface PeerDiscoveryProvider {
[peerDiscoverySymbol]: PeerDiscovery
}
export interface PeerDiscoveryEvents {
'peer': CustomEvent<PeerInfo>
}
export interface PeerDiscovery extends TypedEventTarget<PeerDiscoveryEvents> {}