# ipfs-pubsub-peer-monitor

> Monitor peers joining and leaving an IPFS PubSub topic

Latest version **0.1.0** (published 2023-01-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install ipfs-pubsub-peer-monitor
pnpm add ipfs-pubsub-peer-monitor
yarn add ipfs-pubsub-peer-monitor
bun add ipfs-pubsub-peer-monitor
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2023-01-17 |
| First published | 2018-03-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Haad |
| Maintainers | haad, shamb0t, hajamark |

## Links

- npm: https://www.npmjs.com/package/ipfs-pubsub-peer-monitor
- npm.io page: https://npm.io/package/ipfs-pubsub-peer-monitor

## Dependencies (1)

- [p-forever](https://npm.io/package/p-forever.md) ^2.1.0

## Recent versions

- 0.1.0 (latest) — 2023-01-17
- 0.1.1-6ae7b21.0 (next) — 2023-01-17
- 0.1.1-100bdbe.0 — 2023-01-17
- 0.0.11-ef4183e.0 — 2023-01-08
- 0.0.10 — 2020-09-16
- 0.0.9 — 2019-09-04
- 0.0.8 — 2018-03-31
- 0.0.7 — 2018-03-31
- 0.0.6 — 2018-03-31
- 0.0.5 — 2018-03-31
- 0.0.4 — 2018-03-31
- 0.0.2 — 2018-03-26
- 0.0.1 — 2018-03-25

## README

# ipfs-pubsub-peer-monitor

> Know when peers are joining and leaving an IPFS PubSub topic

`ipfs-pubsub-peer-monitor` listens on a [IPFS PubSub](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PUBSUB.md) topic and emits an event when a peer joins or leaves the topic.

This module is based on [ipfs-pubsub-room](https://github.com/ipfs-shipyard/ipfs-pubsub-room) that can provide the same functionality. It contains extra features that are not necessary for purely wanting to know joins/leaves, so this module was created to do that and only that.

## Usage

```js
import PeerMonitor from 'ipfs-pubsub-peer-monitor'

// Get an IPFS instance somehow
const ipfs = ...

// Topic to monitor
const topic = 'abc'

// Make sure to subscribe to the channel before monitoring it!
ipfs.pubsub.subscribe(topic, (message) => {}, (err, res) => {})

// Pass an IPFS pubsub object and the topic to the monitor
const topicMonitor = new PeerMonitor(ipfs.pubsub, topic)

// When a peer joins the topic
topicMonitor.on('join', peer => console.log("Peer joined", peer))
topicMonitor.on('leave', peer => console.log("Peer left", peer))
topicMonitor.on('error', e => console.error(e))
```

---
_Source: https://npm.io/package/ipfs-pubsub-peer-monitor · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
