# @types/pubsub-js

> TypeScript definitions for pubsub-js

Latest version **1.8.6** (published 2023-11-07) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.8.6 |
| Published | 2023-11-07 |
| First published | 2016-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51442 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/pubsub-js
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/pubsub-js
- npm.io page: https://npm.io/package/@types/pubsub-js

## Recent versions

- 1.8.6 (latest) — 2023-11-07
- 1.8.3 (ts3.7) — 2021-09-23
- 1.8.2 (ts3.4) — 2021-01-14
- 1.8.1 (ts3.1) — 2020-09-11
- 1.8.0 (ts2.9) — 2020-05-01
- 1.5.18 (ts2.0) — 2017-08-21
- 1.8.5 — 2023-10-18
- 1.8.4 — 2023-09-24
- 1.5.17 — 2016-09-19
- 1.5.16 — 2016-07-14
- 1.5.15-alpha — 2016-07-08
- 1.5.14-alpha — 2016-07-04
- 1.5.13-alpha — 2016-07-02
- 1.5.12-alpha — 2016-07-01
- 1.5.11-alpha — 2016-05-25
- … 3 more at https://npm.io/package/@types/pubsub-js/versions

## README

# Installation
> `npm install --save @types/pubsub-js`

# Summary
This package contains type definitions for pubsub-js (https://github.com/mroderick/PubSubJS).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/pubsub-js.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/pubsub-js/index.d.ts)
````ts
declare namespace PubSubJS {
    interface Base<T = any, M = Message>
        extends
            CountSubscriptions,
            ClearAllSubscriptions,
            GetSubscriptions,
            Publish<T, M>,
            Subscribe<T, M>,
            Unsubscribe<T>
    {
        name: string;
        version: string;
    }

    type Token = string;

    type Message = string | symbol;

    type SubscriptionListener<T> = (message: string, data?: T) => void;

    interface CountSubscriptions {
        countSubscriptions(token: Token): number;
    }

    interface ClearAllSubscriptions {
        clearAllSubscriptions(token?: Token): void;
    }

    interface GetSubscriptions {
        getSubscriptions(token: Token): Message[];
    }

    interface Publish<T, M> {
        publish(message: M, data?: T): boolean;

        publishSync(message: M, data?: T): boolean;
    }

    interface Subscribe<T, M> {
        subscribe(message: M, func: SubscriptionListener<T>): Token;

        subscribeOnce(message: M, func: SubscriptionListener<T>): Base<T, M>;
    }

    interface Unsubscribe<T> {
        unsubscribe(tokenOrFunction: Token | SubscriptionListener<T>): Token | boolean;
    }
}

declare var PubSub: PubSubJS.Base;

declare module "pubsub-js" {
    export = PubSub;
}

````

### Additional Details
 * Last updated: Tue, 07 Nov 2023 09:09:39 GMT
 * Dependencies: none

# Credits
These definitions were written by [Boris Yankov](https://github.com/borisyankov), [Matthias Lindinger](https://github.com/morpheus-87), and [Profesor08](https://github.com/Profesor08).

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