@libp2p/peer-collections 5.1.6-fb7c51c3c → 5.1.7
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 +35 -3
- package/dist/src/index.d.ts +18 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +18 -3
- package/dist/src/index.js.map +1 -1
- package/dist/typedoc-urls.json +11 -0
- package/package.json +6 -5
- package/src/index.ts +18 -3
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# @libp2p/peer-collections
|
|
2
|
+
|
|
1
3
|
[](http://libp2p.io/)
|
|
2
4
|
[](https://discuss.libp2p.io)
|
|
3
5
|
[](https://codecov.io/gh/libp2p/js-libp2p)
|
|
@@ -7,6 +9,21 @@
|
|
|
7
9
|
|
|
8
10
|
# About
|
|
9
11
|
|
|
12
|
+
<!--
|
|
13
|
+
|
|
14
|
+
!IMPORTANT!
|
|
15
|
+
|
|
16
|
+
Everything in this README between "# About" and "# Install" is automatically
|
|
17
|
+
generated and will be overwritten the next time the doc generator is run.
|
|
18
|
+
|
|
19
|
+
To make changes to this section, please update the @packageDocumentation section
|
|
20
|
+
of src/index.js or src/index.ts
|
|
21
|
+
|
|
22
|
+
To experiment with formatting, please run "npm run docs" from the root of this
|
|
23
|
+
repo and examine the changes made.
|
|
24
|
+
|
|
25
|
+
-->
|
|
26
|
+
|
|
10
27
|
We can't use PeerIds as collection keys because collection keys are compared using same-value-zero equality, so this is just a group of collections that stringifies PeerIds before storing them.
|
|
11
28
|
|
|
12
29
|
PeerIds cache stringified versions of themselves so this should be a cheap operation.
|
|
@@ -17,6 +34,9 @@ Tracked versions are also available which report their current size to the libp2
|
|
|
17
34
|
|
|
18
35
|
```TypeScript
|
|
19
36
|
import { peerList } from '@libp2p/peer-collections'
|
|
37
|
+
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
38
|
+
|
|
39
|
+
const peerId = await createEd25519PeerId()
|
|
20
40
|
|
|
21
41
|
const list = peerList()
|
|
22
42
|
list.push(peerId)
|
|
@@ -26,9 +46,11 @@ list.push(peerId)
|
|
|
26
46
|
|
|
27
47
|
```TypeScript
|
|
28
48
|
import { trackedPeerList } from '@libp2p/peer-collections'
|
|
49
|
+
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
29
50
|
import { createLibp2p } from 'libp2p'
|
|
30
51
|
|
|
31
52
|
const libp2p = await createLibp2p()
|
|
53
|
+
const peerId = await createEd25519PeerId()
|
|
32
54
|
|
|
33
55
|
const list = trackedPeerList({ name: 'my_metric_name', metrics: libp2p.metrics })
|
|
34
56
|
list.push(peerId)
|
|
@@ -38,6 +60,9 @@ list.push(peerId)
|
|
|
38
60
|
|
|
39
61
|
```TypeScript
|
|
40
62
|
import { peerMap } from '@libp2p/peer-collections'
|
|
63
|
+
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
64
|
+
|
|
65
|
+
const peerId = await createEd25519PeerId()
|
|
41
66
|
|
|
42
67
|
const map = peerMap<string>()
|
|
43
68
|
map.set(peerId, 'value')
|
|
@@ -48,10 +73,12 @@ map.set(peerId, 'value')
|
|
|
48
73
|
```TypeScript
|
|
49
74
|
import { trackedPeerMap } from '@libp2p/peer-collections'
|
|
50
75
|
import { createLibp2p } from 'libp2p'
|
|
76
|
+
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
51
77
|
|
|
52
78
|
const libp2p = await createLibp2p()
|
|
79
|
+
const peerId = await createEd25519PeerId()
|
|
53
80
|
|
|
54
|
-
const
|
|
81
|
+
const map = trackedPeerMap({ name: 'my_metric_name', metrics: libp2p.metrics })
|
|
55
82
|
map.set(peerId, 'value')
|
|
56
83
|
```
|
|
57
84
|
|
|
@@ -59,6 +86,9 @@ map.set(peerId, 'value')
|
|
|
59
86
|
|
|
60
87
|
```TypeScript
|
|
61
88
|
import { peerSet } from '@libp2p/peer-collections'
|
|
89
|
+
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
90
|
+
|
|
91
|
+
const peerId = await createEd25519PeerId()
|
|
62
92
|
|
|
63
93
|
const set = peerSet()
|
|
64
94
|
set.add(peerId)
|
|
@@ -69,11 +99,13 @@ set.add(peerId)
|
|
|
69
99
|
```TypeScript
|
|
70
100
|
import { trackedPeerSet } from '@libp2p/peer-collections'
|
|
71
101
|
import { createLibp2p } from 'libp2p'
|
|
102
|
+
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
72
103
|
|
|
73
104
|
const libp2p = await createLibp2p()
|
|
105
|
+
const peerId = await createEd25519PeerId()
|
|
74
106
|
|
|
75
|
-
const
|
|
76
|
-
|
|
107
|
+
const set = trackedPeerSet({ name: 'my_metric_name', metrics: libp2p.metrics })
|
|
108
|
+
set.add(peerId)
|
|
77
109
|
```
|
|
78
110
|
|
|
79
111
|
# Install
|
package/dist/src/index.d.ts
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
*
|
|
12
12
|
* ```TypeScript
|
|
13
13
|
* import { peerList } from '@libp2p/peer-collections'
|
|
14
|
+
* import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
15
|
+
*
|
|
16
|
+
* const peerId = await createEd25519PeerId()
|
|
14
17
|
*
|
|
15
18
|
* const list = peerList()
|
|
16
19
|
* list.push(peerId)
|
|
@@ -20,9 +23,11 @@
|
|
|
20
23
|
*
|
|
21
24
|
* ```TypeScript
|
|
22
25
|
* import { trackedPeerList } from '@libp2p/peer-collections'
|
|
26
|
+
* import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
23
27
|
* import { createLibp2p } from 'libp2p'
|
|
24
28
|
*
|
|
25
29
|
* const libp2p = await createLibp2p()
|
|
30
|
+
* const peerId = await createEd25519PeerId()
|
|
26
31
|
*
|
|
27
32
|
* const list = trackedPeerList({ name: 'my_metric_name', metrics: libp2p.metrics })
|
|
28
33
|
* list.push(peerId)
|
|
@@ -32,6 +37,9 @@
|
|
|
32
37
|
*
|
|
33
38
|
* ```TypeScript
|
|
34
39
|
* import { peerMap } from '@libp2p/peer-collections'
|
|
40
|
+
* import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
41
|
+
*
|
|
42
|
+
* const peerId = await createEd25519PeerId()
|
|
35
43
|
*
|
|
36
44
|
* const map = peerMap<string>()
|
|
37
45
|
* map.set(peerId, 'value')
|
|
@@ -42,10 +50,12 @@
|
|
|
42
50
|
* ```TypeScript
|
|
43
51
|
* import { trackedPeerMap } from '@libp2p/peer-collections'
|
|
44
52
|
* import { createLibp2p } from 'libp2p'
|
|
53
|
+
* import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
45
54
|
*
|
|
46
55
|
* const libp2p = await createLibp2p()
|
|
56
|
+
* const peerId = await createEd25519PeerId()
|
|
47
57
|
*
|
|
48
|
-
* const
|
|
58
|
+
* const map = trackedPeerMap({ name: 'my_metric_name', metrics: libp2p.metrics })
|
|
49
59
|
* map.set(peerId, 'value')
|
|
50
60
|
* ```
|
|
51
61
|
*
|
|
@@ -53,6 +63,9 @@
|
|
|
53
63
|
*
|
|
54
64
|
* ```TypeScript
|
|
55
65
|
* import { peerSet } from '@libp2p/peer-collections'
|
|
66
|
+
* import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
67
|
+
*
|
|
68
|
+
* const peerId = await createEd25519PeerId()
|
|
56
69
|
*
|
|
57
70
|
* const set = peerSet()
|
|
58
71
|
* set.add(peerId)
|
|
@@ -63,11 +76,13 @@
|
|
|
63
76
|
* ```TypeScript
|
|
64
77
|
* import { trackedPeerSet } from '@libp2p/peer-collections'
|
|
65
78
|
* import { createLibp2p } from 'libp2p'
|
|
79
|
+
* import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
66
80
|
*
|
|
67
81
|
* const libp2p = await createLibp2p()
|
|
82
|
+
* const peerId = await createEd25519PeerId()
|
|
68
83
|
*
|
|
69
|
-
* const
|
|
70
|
-
*
|
|
84
|
+
* const set = trackedPeerSet({ name: 'my_metric_name', metrics: libp2p.metrics })
|
|
85
|
+
* set.add(peerId)
|
|
71
86
|
* ```
|
|
72
87
|
*/
|
|
73
88
|
export { PeerMap, peerMap } from './map.js';
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsFG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA"}
|
package/dist/src/index.js
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
*
|
|
12
12
|
* ```TypeScript
|
|
13
13
|
* import { peerList } from '@libp2p/peer-collections'
|
|
14
|
+
* import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
15
|
+
*
|
|
16
|
+
* const peerId = await createEd25519PeerId()
|
|
14
17
|
*
|
|
15
18
|
* const list = peerList()
|
|
16
19
|
* list.push(peerId)
|
|
@@ -20,9 +23,11 @@
|
|
|
20
23
|
*
|
|
21
24
|
* ```TypeScript
|
|
22
25
|
* import { trackedPeerList } from '@libp2p/peer-collections'
|
|
26
|
+
* import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
23
27
|
* import { createLibp2p } from 'libp2p'
|
|
24
28
|
*
|
|
25
29
|
* const libp2p = await createLibp2p()
|
|
30
|
+
* const peerId = await createEd25519PeerId()
|
|
26
31
|
*
|
|
27
32
|
* const list = trackedPeerList({ name: 'my_metric_name', metrics: libp2p.metrics })
|
|
28
33
|
* list.push(peerId)
|
|
@@ -32,6 +37,9 @@
|
|
|
32
37
|
*
|
|
33
38
|
* ```TypeScript
|
|
34
39
|
* import { peerMap } from '@libp2p/peer-collections'
|
|
40
|
+
* import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
41
|
+
*
|
|
42
|
+
* const peerId = await createEd25519PeerId()
|
|
35
43
|
*
|
|
36
44
|
* const map = peerMap<string>()
|
|
37
45
|
* map.set(peerId, 'value')
|
|
@@ -42,10 +50,12 @@
|
|
|
42
50
|
* ```TypeScript
|
|
43
51
|
* import { trackedPeerMap } from '@libp2p/peer-collections'
|
|
44
52
|
* import { createLibp2p } from 'libp2p'
|
|
53
|
+
* import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
45
54
|
*
|
|
46
55
|
* const libp2p = await createLibp2p()
|
|
56
|
+
* const peerId = await createEd25519PeerId()
|
|
47
57
|
*
|
|
48
|
-
* const
|
|
58
|
+
* const map = trackedPeerMap({ name: 'my_metric_name', metrics: libp2p.metrics })
|
|
49
59
|
* map.set(peerId, 'value')
|
|
50
60
|
* ```
|
|
51
61
|
*
|
|
@@ -53,6 +63,9 @@
|
|
|
53
63
|
*
|
|
54
64
|
* ```TypeScript
|
|
55
65
|
* import { peerSet } from '@libp2p/peer-collections'
|
|
66
|
+
* import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
67
|
+
*
|
|
68
|
+
* const peerId = await createEd25519PeerId()
|
|
56
69
|
*
|
|
57
70
|
* const set = peerSet()
|
|
58
71
|
* set.add(peerId)
|
|
@@ -63,11 +76,13 @@
|
|
|
63
76
|
* ```TypeScript
|
|
64
77
|
* import { trackedPeerSet } from '@libp2p/peer-collections'
|
|
65
78
|
* import { createLibp2p } from 'libp2p'
|
|
79
|
+
* import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
66
80
|
*
|
|
67
81
|
* const libp2p = await createLibp2p()
|
|
82
|
+
* const peerId = await createEd25519PeerId()
|
|
68
83
|
*
|
|
69
|
-
* const
|
|
70
|
-
*
|
|
84
|
+
* const set = trackedPeerSet({ name: 'my_metric_name', metrics: libp2p.metrics })
|
|
85
|
+
* set.add(peerId)
|
|
71
86
|
* ```
|
|
72
87
|
*/
|
|
73
88
|
export { PeerMap, peerMap } from './map.js';
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsFG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -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.1.
|
|
3
|
+
"version": "5.1.7",
|
|
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",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"clean": "aegir clean",
|
|
44
44
|
"lint": "aegir lint",
|
|
45
45
|
"dep-check": "aegir dep-check",
|
|
46
|
+
"doc-check": "aegir doc-check",
|
|
46
47
|
"build": "aegir build",
|
|
47
48
|
"test": "aegir test",
|
|
48
49
|
"test:chrome": "aegir test -t browser --cov",
|
|
@@ -53,13 +54,13 @@
|
|
|
53
54
|
"test:electron-main": "aegir test -t electron-main"
|
|
54
55
|
},
|
|
55
56
|
"dependencies": {
|
|
56
|
-
"@libp2p/interface": "1.1.
|
|
57
|
-
"@libp2p/peer-id": "4.0.
|
|
57
|
+
"@libp2p/interface": "^1.1.4",
|
|
58
|
+
"@libp2p/peer-id": "^4.0.7"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
|
-
"@libp2p/peer-id-factory": "4.0.
|
|
61
|
+
"@libp2p/peer-id-factory": "^4.0.7",
|
|
61
62
|
"@types/sinon": "^17.0.3",
|
|
62
|
-
"aegir": "^42.2.
|
|
63
|
+
"aegir": "^42.2.4",
|
|
63
64
|
"sinon": "^17.0.1",
|
|
64
65
|
"sinon-ts": "^2.0.0"
|
|
65
66
|
},
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
*
|
|
12
12
|
* ```TypeScript
|
|
13
13
|
* import { peerList } from '@libp2p/peer-collections'
|
|
14
|
+
* import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
15
|
+
*
|
|
16
|
+
* const peerId = await createEd25519PeerId()
|
|
14
17
|
*
|
|
15
18
|
* const list = peerList()
|
|
16
19
|
* list.push(peerId)
|
|
@@ -20,9 +23,11 @@
|
|
|
20
23
|
*
|
|
21
24
|
* ```TypeScript
|
|
22
25
|
* import { trackedPeerList } from '@libp2p/peer-collections'
|
|
26
|
+
* import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
23
27
|
* import { createLibp2p } from 'libp2p'
|
|
24
28
|
*
|
|
25
29
|
* const libp2p = await createLibp2p()
|
|
30
|
+
* const peerId = await createEd25519PeerId()
|
|
26
31
|
*
|
|
27
32
|
* const list = trackedPeerList({ name: 'my_metric_name', metrics: libp2p.metrics })
|
|
28
33
|
* list.push(peerId)
|
|
@@ -32,6 +37,9 @@
|
|
|
32
37
|
*
|
|
33
38
|
* ```TypeScript
|
|
34
39
|
* import { peerMap } from '@libp2p/peer-collections'
|
|
40
|
+
* import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
41
|
+
*
|
|
42
|
+
* const peerId = await createEd25519PeerId()
|
|
35
43
|
*
|
|
36
44
|
* const map = peerMap<string>()
|
|
37
45
|
* map.set(peerId, 'value')
|
|
@@ -42,10 +50,12 @@
|
|
|
42
50
|
* ```TypeScript
|
|
43
51
|
* import { trackedPeerMap } from '@libp2p/peer-collections'
|
|
44
52
|
* import { createLibp2p } from 'libp2p'
|
|
53
|
+
* import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
45
54
|
*
|
|
46
55
|
* const libp2p = await createLibp2p()
|
|
56
|
+
* const peerId = await createEd25519PeerId()
|
|
47
57
|
*
|
|
48
|
-
* const
|
|
58
|
+
* const map = trackedPeerMap({ name: 'my_metric_name', metrics: libp2p.metrics })
|
|
49
59
|
* map.set(peerId, 'value')
|
|
50
60
|
* ```
|
|
51
61
|
*
|
|
@@ -53,6 +63,9 @@
|
|
|
53
63
|
*
|
|
54
64
|
* ```TypeScript
|
|
55
65
|
* import { peerSet } from '@libp2p/peer-collections'
|
|
66
|
+
* import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
67
|
+
*
|
|
68
|
+
* const peerId = await createEd25519PeerId()
|
|
56
69
|
*
|
|
57
70
|
* const set = peerSet()
|
|
58
71
|
* set.add(peerId)
|
|
@@ -63,11 +76,13 @@
|
|
|
63
76
|
* ```TypeScript
|
|
64
77
|
* import { trackedPeerSet } from '@libp2p/peer-collections'
|
|
65
78
|
* import { createLibp2p } from 'libp2p'
|
|
79
|
+
* import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
66
80
|
*
|
|
67
81
|
* const libp2p = await createLibp2p()
|
|
82
|
+
* const peerId = await createEd25519PeerId()
|
|
68
83
|
*
|
|
69
|
-
* const
|
|
70
|
-
*
|
|
84
|
+
* const set = trackedPeerSet({ name: 'my_metric_name', metrics: libp2p.metrics })
|
|
85
|
+
* set.add(peerId)
|
|
71
86
|
* ```
|
|
72
87
|
*/
|
|
73
88
|
|