@libp2p/pubsub 9.0.10-fb7c51c3c → 9.0.11-1fc929c1c

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ # @libp2p/pubsub
2
+
1
3
  [![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
2
4
  [![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
3
5
  [![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p)
@@ -5,6 +7,51 @@
5
7
 
6
8
  > libp2p pubsub base class
7
9
 
10
+ # About
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
+
27
+ A set of components to be extended in order to create a pubsub implementation.
28
+
29
+ ## Example
30
+
31
+ ```TypeScript
32
+ import { PubSubBaseProtocol } from '@libp2p/pubsub'
33
+ import type { PubSubRPC, PublishResult, PubSubRPCMessage, PeerId, Message } from '@libp2p/interface'
34
+ import type { Uint8ArrayList } from 'uint8arraylist'
35
+
36
+ class MyPubsubImplementation extends PubSubBaseProtocol {
37
+ decodeRpc (bytes: Uint8Array | Uint8ArrayList): PubSubRPC {
38
+ throw new Error('Not implemented')
39
+ }
40
+
41
+ encodeRpc (rpc: PubSubRPC): Uint8Array {
42
+ throw new Error('Not implemented')
43
+ }
44
+
45
+ encodeMessage (rpc: PubSubRPCMessage): Uint8Array {
46
+ throw new Error('Not implemented')
47
+ }
48
+
49
+ async publishMessage (sender: PeerId, message: Message): Promise<PublishResult> {
50
+ throw new Error('Not implemented')
51
+ }
52
+ }
53
+ ```
54
+
8
55
  # Install
9
56
 
10
57
  ```console