# @ianwalter/subpub

> A super-simple JavaScript Subscribe/Publish (pubsub) implementation

Latest version **3.0.0** (published 2020-04-13) · SEE LICENSE IN LICENSE license · 0 weekly downloads

## Install

```sh
npm install @ianwalter/subpub
pnpm add @ianwalter/subpub
yarn add @ianwalter/subpub
bun add @ianwalter/subpub
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2020-04-13 |
| First published | 2018-10-20 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ian Walter |
| Maintainers | ianwalter |
| Keywords | publish, subscribe, pubsub, subscriptions, topics, channels, events, pattern-matching |

## Links

- npm: https://www.npmjs.com/package/@ianwalter/subpub
- npm.io page: https://npm.io/package/@ianwalter/subpub

## Dependencies (1)

- [patrun](https://npm.io/package/patrun.md) ^3.0.0

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 3.0.0 (latest) — 2020-04-13
- 2.0.0 — 2019-03-03
- 1.0.1 — 2019-02-03
- 1.0.0 — 2018-10-20

## README

# @ianwalter/subpub
> A super-simple JavaScript Subscribe/Publish (pubsub) implementation

[![npm page][npmImage]][npmUrl]

## Installation

```console
yarn add @ianwalter/subpub
```

## Usage

```js
import { Subpub } from '@ianwalter/subpub'

// Create a Subpub instance.
const sp = new Subpub()

// Create a subscription to a topic.
const usubscribe = sp.sub('alerts', msg => console.log(msg))

// Publish a message on the topic.
sp.pub('alerts', 'We ran out of coffee!')

// Unsubscribe the subscriber from the topic.
usubscribe()

// Create a subscriber with an object key that can be pattern-matched.
sp.sub({ key: '1d', name: 'BIBA' }, async msg => msg.toUpperCase())

// Send a message to the subscriber using only the key property to match and
// wait for the returned promise to resolve with the transformed value.
await sp.pub({ key: '1d' }, 'Te biba nachdi') // => TE BIBA NACHDI
```

## License

Apache 2.0 with Commons Clause - See [LICENSE][licenseUrl]

&nbsp;

Created by [Ian Walter](https://ianwalter.dev)

[npmImage]: https://img.shields.io/npm/v/@ianwalter/subpub.svg
[npmUrl]: https://www.npmjs.com/package/@ianwalter/subpub
[licenseUrl]: https://github.com/ianwalter/subpub/blob/master/LICENSE

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