@libp2p/floodsub 4.0.1 → 6.0.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
@@ -1,20 +1,20 @@
1
1
  # @libp2p/floodsub <!-- omit in toc -->
2
2
 
3
3
  [![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
4
- [![IRC](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)
5
4
  [![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
6
5
  [![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-floodsub.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-floodsub)
7
- [![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/libp2p/js-libp2p-floodsub/actions/workflows/js-test-and-release.yml)
6
+ [![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p-floodsub/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/libp2p/js-libp2p-floodsub/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)
8
7
 
9
8
  > libp2p-floodsub, also known as pubsub-flood or just dumbsub, this implementation of pubsub focused on delivering an API for Publish/Subscribe, but with no CastTree Forming (it just floods the network).
10
9
 
11
10
  ## Table of contents <!-- omit in toc -->
12
11
 
13
12
  - [Install](#install)
13
+ - [Browser `<script>` tag](#browser-script-tag)
14
14
  - [Don't use this module](#dont-use-this-module)
15
15
  - [Usage](#usage)
16
16
  - [License](#license)
17
- - [Contribute](#contribute)
17
+ - [Contribution](#contribution)
18
18
 
19
19
  ## Install
20
20
 
@@ -22,6 +22,14 @@
22
22
  $ npm i @libp2p/floodsub
23
23
  ```
24
24
 
25
+ ### Browser `<script>` tag
26
+
27
+ Loading this module through a script tag will make it's exports available as `Libp2pFloodsub` in the global namespace.
28
+
29
+ ```html
30
+ <script src="https://unpkg.com/@libp2p/floodsub/dist/index.min.js"></script>
31
+ ```
32
+
25
33
  ## Don't use this module
26
34
 
27
35
  This module is a naive implementation of pubsub. It broadcasts all messages to all network peers, cannot provide older messages and has no protection against bad actors.
@@ -33,18 +41,21 @@ Instead please use [gossipsub](https://www.npmjs.com/package/@chainsafe/libp2p-g
33
41
  ## Usage
34
42
 
35
43
  ```JavaScript
36
- import { FloodSub } from '@libp2p/floodsub'
37
-
38
- const fsub = new FloodSub()
44
+ import { createLibp2pNode } from 'libp2p'
45
+ import { floodsub } from '@libp2p/floodsub'
39
46
 
40
- await fsub.start()
47
+ const node = await createLibp2pNode({
48
+ pubsub: floodsub()
49
+ //... other options
50
+ })
51
+ await node.start()
41
52
 
42
- fsub.addEventListener('message', (data) => {
43
- console.log(data)
53
+ node.pubsub.subscribe('fruit')
54
+ node.pubsub.addEventListener('message', (evt) => {
55
+ console.log(evt)
44
56
  })
45
- fsub.subscribe('fruit')
46
57
 
47
- fsub.publish('fruit', new TextEncoder().encode('banana'))
58
+ node.pubsub.publish('fruit', new TextEncoder().encode('banana'))
48
59
  ```
49
60
 
50
61
  ## License
@@ -54,6 +65,6 @@ Licensed under either of
54
65
  - Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
55
66
  - MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
56
67
 
57
- ## Contribute
68
+ ## Contribution
58
69
 
59
70
  Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.