# @blackglory/pubsub-js

> ```sh npm install --save @blackglory/pubsub-js # or yarn add @blackglory/pubsub-js ```

Latest version **9.1.2** (published 2026-05-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @blackglory/pubsub-js
pnpm add @blackglory/pubsub-js
yarn add @blackglory/pubsub-js
bun add @blackglory/pubsub-js
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 9.1.2 |
| Published | 2026-05-24 |
| First published | 2020-12-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 9 |
| Unpacked size | 17.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | BlackGlory |
| Maintainers | black_glory |

## Links

- npm: https://www.npmjs.com/package/@blackglory/pubsub-js
- Repository: https://github.com/BlackGlory/pubsub-js
- Homepage: https://github.com/BlackGlory/pubsub-js#readme
- Issues: https://github.com/BlackGlory/pubsub-js/issues
- npm.io page: https://npm.io/package/@blackglory/pubsub-js

## Dependencies (9)

- [extra-sse](https://npm.io/package/extra-sse.md) ^0.5.0
- [extra-abort](https://npm.io/package/extra-abort.md) ^0.5.1
- [extra-fetch](https://npm.io/package/extra-fetch.md) ^5.2.0
- [extra-timers](https://npm.io/package/extra-timers.md) ^0.3.1
- [extra-request](https://npm.io/package/extra-request.md) ^11.2.0
- [extra-response](https://npm.io/package/extra-response.md) ^0.6.1
- [@blackglory/errors](https://npm.io/package/@blackglory/errors.md) ^3.1.0
- [@blackglory/prelude](https://npm.io/package/@blackglory/prelude.md) ^0.4.0
- [@blackglory/http-status](https://npm.io/package/@blackglory/http-status.md) ^2.0.4

## Recent versions

- 9.1.2 (latest) — 2026-05-24
- 9.1.1 — 2026-04-20
- 9.1.0 — 2026-02-16
- 9.0.0 — 2025-06-16
- 8.1.0 — 2025-06-12
- 8.0.0 — 2023-08-02
- 7.0.1 — 2023-06-11
- 7.0.0 — 2023-03-17
- 6.1.0 — 2023-03-13
- 6.0.0 — 2023-02-06
- 5.0.0 — 2023-01-30
- 4.0.2 — 2022-10-31
- 4.0.1 — 2022-10-23
- 4.0.0 — 2022-10-21
- 3.2.3 — 2022-09-30
- … 48 more at https://npm.io/package/@blackglory/pubsub-js/versions

## README

# pubsub-js
## Install
```sh
npm install --save @blackglory/pubsub-js
# or
yarn add @blackglory/pubsub-js
```

## API
### PubSubClient
```ts
interface IPubSubClientOptions {
  server: string
  basicAuth?: {
    username: string
    password: string
  }
  keepalive?: boolean
  heartbeat?: IHeartbeatOptions
  timeout?: number
}

interface IPubSubClientRequestOptions {
  signal?: AbortSignal
  keepalive?: boolean
  timeout?: number | false
}

export interface IPubSubClientSubscribeOptions extends IPubSubClientRequestOptions {
  heartbeat?: IHeartbeatOptions
}

interface IHeartbeatOptions {
  timeout: number
}

class PubSubClient {
  constructor(options: IPubSubClientOptions)

  publish(
    namespace: string
  , channel: string
  , content: JSONValue
  , options?: IPubSubClientRequestOptions
  ): Promise<void>

  subscribe(
    namespace: string
  , channel: string
  , options?: IPubSubClientSubscribeOptions
  ): AsyncIterableIterator<JSONValue>
}
```

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