# subnpub

> Publish/Subscribe pattern

Latest version **1.1.8** (published 2019-07-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install subnpub
pnpm add subnpub
yarn add subnpub
bun add subnpub
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.8 |
| Published | 2019-07-16 |
| First published | 2017-10-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | stormcrows |
| Maintainers | stormcrows |
| Keywords | publish, subscribe, pattern |

## Links

- npm: https://www.npmjs.com/package/subnpub
- Repository: https://github.com/stormcrows/subnpub
- Homepage: https://github.com/stormcrows/subnpub#readme
- Issues: https://github.com/stormcrows/subnpub/issues
- npm.io page: https://npm.io/package/subnpub

## Recent versions

- 1.1.8 (latest) — 2019-07-16
- 1.1.7 — 2017-11-06
- 1.1.6 — 2017-10-24
- 1.1.5 — 2017-10-22
- 1.1.4 — 2017-10-18
- 1.1.3 — 2017-10-18
- 1.1.2 — 2017-10-17
- 1.1.1 — 2017-10-15
- 1.1.0 — 2017-10-15
- 1.0.1 — 2017-10-14
- 1.0.0 — 2017-10-14

## README

# subnpub

[![CircleCI](https://circleci.com/gh/stormcrows/subnpub/tree/master.svg?style=svg)](https://circleci.com/gh/stormcrows/subnpub/tree/master)

Minimal implementation of publish/subscribe pattern

## USAGE

```javascript
const SubNPub = require("subnpub");
const snp = SubNPub();

const fn1 = str => `1-Called Me with: ${str}`;
const fn2 = str => `2-Called Me with: ${str}`;
const fn3 = str => `3-Called Me with: ${str}`;

// subscribe enforces uniqueness
snp.subscribe(fn1);
// or:
snp.subscribe(fn1, fn2, fn3);
// or:
snp.subscribe([fn1, fn2, fn3]);


snp.publish("test"); // dispatches argument to all subscribers

snp.has(fn1); // true

snp.length(); // 3


snp.unsubscribe(fn1); // removes subscriber
// or:
snp.unsubscribe(fn1, fn2, fn3);
// or:
snp.unsubscribe([fn1, fn2, fn3]);

snp.reset(); // removes all subscribers
```

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