@libp2p/peer-collections 5.0.0-d10506189 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,6 +11,81 @@ We can't use PeerIds as collection keys because collection keys are compared usi
11
11
 
12
12
  PeerIds cache stringified versions of themselves so this should be a cheap operation.
13
13
 
14
+ Tracked versions are also available which report their current size to the libp2p Metrics collector.
15
+
16
+ ## Example - Peer lists
17
+
18
+ ```JavaScript
19
+ import { peerList } from '@libp2p/peer-collections'
20
+
21
+ const list = peerList()
22
+ list.push(peerId)
23
+ ```
24
+
25
+ ## Example - Tracked peer lists
26
+
27
+ - ```Typescript
28
+ ```
29
+
30
+ import { trackedPeerList } from '@libp2p/peer-collections'
31
+ import { createLibp2p } from 'libp2p'
32
+
33
+ const libp2p = await createLibp2p()
34
+
35
+ const list = trackedPeerList({ name: 'my\_metric\_name', metrics: libp2p.metrics })
36
+ list.push(peerId)
37
+
38
+ ````
39
+
40
+ ## Example - Peer maps
41
+
42
+ ```JavaScript
43
+ import { peerMap } from '@libp2p/peer-collections'
44
+
45
+ const map = peerMap<string>()
46
+ map.set(peerId, 'value')
47
+ ````
48
+
49
+ ## Example - Tracked peer maps
50
+
51
+ - ```Typescript
52
+ ```
53
+
54
+ import { trackedPeerMap } from '@libp2p/peer-collections'
55
+ import { createLibp2p } from 'libp2p'
56
+
57
+ const libp2p = await createLibp2p()
58
+
59
+ const list = trackedPeerMap({ name: 'my\_metric\_name', metrics: libp2p.metrics })
60
+ map.set(peerId, 'value')
61
+
62
+ ````
63
+
64
+ ## Example - Peer sets
65
+
66
+ ```JavaScript
67
+ import { peerSet } from '@libp2p/peer-collections'
68
+
69
+ const set = peerSet()
70
+ set.add(peerId)
71
+ ````
72
+
73
+ ## Example - Tracked peer sets
74
+
75
+ - ```Typescript
76
+ ```
77
+
78
+ import { trackedPeerSet } from '@libp2p/peer-collections'
79
+ import { createLibp2p } from 'libp2p'
80
+
81
+ const libp2p = await createLibp2p()
82
+
83
+ const list = trackedPeerSet({ name: 'my\_metric\_name', metrics: libp2p.metrics })
84
+ map.add(peerId)
85
+
86
+ ```
87
+ ```
88
+
14
89
  # Install
15
90
 
16
91
  ```console
@@ -0,0 +1,11 @@
1
+ {
2
+ "PeerList": "https://libp2p.github.io/js-libp2p/classes/_libp2p_peer_collections.PeerList.html",
3
+ "PeerMap": "https://libp2p.github.io/js-libp2p/classes/_libp2p_peer_collections.PeerMap.html",
4
+ "PeerSet": "https://libp2p.github.io/js-libp2p/classes/_libp2p_peer_collections.PeerSet.html",
5
+ "peerList": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.peerList-1.html",
6
+ "peerMap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.peerMap-1.html",
7
+ "peerSet": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.peerSet-1.html",
8
+ "trackedPeerList": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.trackedPeerList.html",
9
+ "trackedPeerMap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.trackedPeerMap.html",
10
+ "trackedPeerSet": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.trackedPeerSet.html"
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/peer-collections",
3
- "version": "5.0.0-d10506189",
3
+ "version": "5.1.0",
4
4
  "description": "Stores values against a peer id",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-collections#readme",
@@ -53,11 +53,11 @@
53
53
  "test:electron-main": "aegir test -t electron-main"
54
54
  },
55
55
  "dependencies": {
56
- "@libp2p/interface": "1.0.1-d10506189",
57
- "@libp2p/peer-id": "4.0.1-d10506189"
56
+ "@libp2p/interface": "^1.0.1",
57
+ "@libp2p/peer-id": "^4.0.1"
58
58
  },
59
59
  "devDependencies": {
60
- "@libp2p/peer-id-factory": "4.0.0-d10506189",
60
+ "@libp2p/peer-id-factory": "^4.0.0",
61
61
  "@types/sinon": "^17.0.2",
62
62
  "aegir": "^41.0.2",
63
63
  "sinon": "^17.0.1",