Socket
Socket
Sign inDemoInstall

@dldc/pubsub

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dldc/pubsub - npm Package Compare versions

Comparing version 5.2.5 to 6.0.0

6

dist/mod.d.ts

@@ -72,3 +72,3 @@ import { TVoidKey, Erreur, TKey } from '@dldc/erreur';

}
declare const Suub: {
declare const PubSub: {
createSubscription: <Data, Channel = any>(options?: ISubscriptionOptions) => ISubscription<Data, Channel>;

@@ -78,3 +78,3 @@ createVoidSubscription: <Channel_1 = any>(options?: ISubscriptionOptions) => IVoidSubscription<Channel_1>;

};
declare const SuubErreur: {
declare const PubSubErreur: {
SubscriptionDestroyed: {

@@ -106,2 +106,2 @@ Key: TVoidKey;

export { ChannelMethod, DeferredMethod, IMultiSubscription, ISubscription, ISubscriptionOptions, IVoidSubscription, IsSubscribedByIdMethod, IsSubscribedMethod, MultiCreateChannelMethod, MultiCreateVoidChannelMethod, OnUnsubscribed, SubscribeByIdMethod, SubscribeMethod, SubscriptionCallback, Suub, SuubErreur, Unsubscribe, UnsubscribeAllMethod, UnsubscribeByIdMethod, UnsubscribeMethod, VoidChannelMethod, VoidIsSubscribedByIdMethod, VoidIsSubscribedMethod, VoidSubscribeByIdMethod, VoidSubscribeMethod, VoidSubscriptionCallback, VoidUnsubscribeByIdMethod, VoidUnsubscribeMethod };
export { ChannelMethod, DeferredMethod, IMultiSubscription, ISubscription, ISubscriptionOptions, IVoidSubscription, IsSubscribedByIdMethod, IsSubscribedMethod, MultiCreateChannelMethod, MultiCreateVoidChannelMethod, OnUnsubscribed, PubSub, PubSubErreur, SubscribeByIdMethod, SubscribeMethod, SubscriptionCallback, Unsubscribe, UnsubscribeAllMethod, UnsubscribeByIdMethod, UnsubscribeMethod, VoidChannelMethod, VoidIsSubscribedByIdMethod, VoidIsSubscribedMethod, VoidSubscribeByIdMethod, VoidSubscribeMethod, VoidSubscriptionCallback, VoidUnsubscribeByIdMethod, VoidUnsubscribeMethod };

@@ -23,8 +23,8 @@ "use strict";

__export(mod_exports, {
Suub: () => Suub,
SuubErreur: () => SuubErreur
PubSub: () => PubSub,
PubSubErreur: () => PubSubErreur
});
module.exports = __toCommonJS(mod_exports);
var import_erreur = require("@dldc/erreur");
var Suub = (() => {
var PubSub = (() => {
const DEFAULT_CHANNEL = Symbol("DEFAULT_CHANNEL");

@@ -144,3 +144,3 @@ return { createSubscription, createVoidSubscription, createMultiSubscription };

if (destroyed) {
throw SuubErreur.SubscriptionDestroyed.create();
throw PubSubErreur.SubscriptionDestroyed.create();
}

@@ -179,3 +179,3 @@ emitQueue.push({ value: newValue, channel });

isEmitting = false;
throw SuubErreur.MaxSubscriptionCountReached.create();
throw PubSubErreur.MaxSubscriptionCountReached.create();
}

@@ -185,3 +185,3 @@ }

if (emitQueueSafe <= 0) {
throw SuubErreur.MaxRecursiveEmitReached.create(maxRecursiveEmit);
throw PubSubErreur.MaxRecursiveEmitReached.create(maxRecursiveEmit);
}

@@ -203,3 +203,3 @@ }

if (safe <= 0) {
throw SuubErreur.MaxUnsubscribeAllLoopReached.create(maxUnsubscribeAllLoop);
throw PubSubErreur.MaxUnsubscribeAllLoopReached.create(maxUnsubscribeAllLoop);
}

@@ -210,6 +210,6 @@ return;

if (destroyed) {
throw SuubErreur.SubscriptionDestroyed.create();
throw PubSubErreur.SubscriptionDestroyed.create();
}
if (typeof callback !== "function") {
throw SuubErreur.InvalidCallback.create();
throw PubSubErreur.InvalidCallback.create();
}

@@ -277,3 +277,3 @@ const alreadySubscribed = findSubscription(channel, subId, callback);

})();
var SuubErreur = (() => {
var PubSubErreur = (() => {
const SubscriptionDestroyedKey = import_erreur.Key.createEmpty("SubscriptionDestroyed");

@@ -288,3 +288,5 @@ const MaxSubscriptionCountReachedKey = import_erreur.Key.createEmpty("MaxSubscriptionCountReached");

create() {
return import_erreur.Erreur.createWith(SubscriptionDestroyedKey).withMessage(`The subscription has been destroyed`);
return import_erreur.Erreur.create(new Error("The subscription has been destroyed")).with(
SubscriptionDestroyedKey.Provider()
);
}

@@ -295,5 +297,7 @@ },

create() {
return import_erreur.Erreur.createWith(MaxSubscriptionCountReachedKey).withMessage(
`The maxSubscriptionCount has been reached. If this is expected you can use the maxSubscriptionCount option to raise the limit`
);
return import_erreur.Erreur.create(
new Error(
`The maxSubscriptionCount has been reached. If this is expected you can use the maxSubscriptionCount option to raise the limit`
)
).with(MaxSubscriptionCountReachedKey.Provider());
}

@@ -304,5 +308,7 @@ },

create(limit) {
return import_erreur.Erreur.createWith(MaxRecursiveEmitReachedKey, { limit }).withMessage(
`The maxRecursiveEmit limit (${limit}) has been reached, did you emit() in a callback ? If this is expected you can use the maxRecursiveEmit option to raise the limit`
);
return import_erreur.Erreur.create(
new Error(
`The maxRecursiveEmit limit (${limit}) has been reached, did you emit() in a callback ? If this is expected you can use the maxRecursiveEmit option to raise the limit`
)
).with(MaxRecursiveEmitReachedKey.Provider({ limit }));
}

@@ -313,5 +319,7 @@ },

create(limit) {
return import_erreur.Erreur.createWith(MaxUnsubscribeAllLoopReachedKey, { limit }).withMessage(
`The maxUnsubscribeAllLoop limit (${limit}) has been reached, did you call subscribe() in the onUnsubscribe callback then called unsubscribeAll ? If this is expected you can use the maxUnsubscribeAllLoop option to raise the limit`
);
return import_erreur.Erreur.create(
new Error(
`The maxUnsubscribeAllLoop limit (${limit}) has been reached, did you call subscribe() in the onUnsubscribe callback then called unsubscribeAll ? If this is expected you can use the maxUnsubscribeAllLoop option to raise the limit`
)
).with(MaxUnsubscribeAllLoopReachedKey.Provider({ limit }));
}

@@ -322,3 +330,3 @@ },

create() {
return import_erreur.Erreur.createWith(InvalidCallbackKey).withMessage(`The callback is not a function`);
return import_erreur.Erreur.create(new Error(`The callback is not a function`)).with(InvalidCallbackKey.Provider());
}

@@ -330,4 +338,4 @@ }

0 && (module.exports = {
Suub,
SuubErreur
PubSub,
PubSubErreur
});
{
"name": "@dldc/pubsub",
"version": "5.2.5",
"version": "6.0.0",
"description": "A simple pub/sub written in Typescript",

@@ -89,11 +89,11 @@ "keywords": [

"dependencies": {
"@dldc/erreur": "^5.0.0"
"@dldc/erreur": "^6.0.0"
},
"devDependencies": {
"@types/node": "^20.8.3",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"@types/node": "^20.8.10",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"@vitest/coverage-v8": "^0.34.6",
"auto-changelog": "^2.4.0",
"eslint": "^8.51.0",
"eslint": "^8.52.0",
"eslint-config-prettier": "^9.0.0",

@@ -107,3 +107,3 @@ "prettier": "^3.0.3",

},
"packageManager": "pnpm@8.6.1",
"packageManager": "pnpm@8.9.0",
"publishConfig": {

@@ -110,0 +110,0 @@ "access": "public",

<p align="center">
<img src="https://raw.githubusercontent.com/etienne-dldc/suub/main/design/logo.png" width="597" alt="suub logo">
<img src="https://raw.githubusercontent.com/dldc-packages/pubsub/main/design/logo.png" width="597" alt="pubsub logo">
</p>
# 📫 Suub
# 📫 PubSub
> A simple pub/sub written in Typescript
```
npm install @dldc/pubsub
```
## Gist
```ts
import { Suub } from 'suub';
import { PubSub } from '@dldc/pubsub';
const mySub = Suub.createSubscription<number>();
const mySub = PubSub.createSubscription<number>();

@@ -29,24 +33,24 @@ const unsub = mySub.subscribe((num) => {

To create a `Subscription` you need to import the `Suub.createSubscription` function and call it.
To create a `Subscription` you need to import the `PubSub.createSubscription` function and call it.
```ts
import { Suub } from 'suub';
import { PubSub } from '@dldc/pubsub';
const subscription = Suub.createSubscription();
const subscription = PubSub.createSubscription();
```
If you use TypeScript, you need to pass a type parameter to the `Suub.createSubscription` function to define the type of the value associated with the subscription.
If you use TypeScript, you need to pass a type parameter to the `PubSub.createSubscription` function to define the type of the value associated with the subscription.
```ts
import { Suub } from 'suub';
import { PubSub } from '@dldc/pubsub';
const numSubscription = Suub.createSubscription<number>();
const numSubscription = PubSub.createSubscription<number>();
```
If you don't want your subscription not to emit any value, you can use the `Suub.createVoidSubscription` function.
If you don't want your subscription not to emit any value, you can use the `PubSub.createVoidSubscription` function.
```ts
import { Suub } from 'suub';
import { PubSub } from '@dldc/pubsub';
const voidSubscription = Suub.createVoidSubscription();
const voidSubscription = PubSub.createVoidSubscription();
```

@@ -243,6 +247,2 @@

## Examples
Take a look at the [Examples folder](https://github.com/etienne-dldc/suub/tree/master/examples).
## API

@@ -249,0 +249,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc