New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@graphql-yoga/subscription

Package Overview
Dependencies
Maintainers
4
Versions
1280
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-yoga/subscription - npm Package Compare versions

Comparing version 5.0.2-alpha-20240728232210-e814a390 to 5.1.0-alpha-20241003102906-3b853548

36

cjs/create-pub-sub.js

@@ -5,2 +5,3 @@ "use strict";

const repeater_1 = require("@repeaterjs/repeater");
const events_1 = require("@whatwg-node/events");
/**

@@ -11,2 +12,22 @@ * Utility for publishing and subscribing to events.

const target = config?.eventTarget ?? new EventTarget();
function subscribe(...args) {
let topic;
let buffer;
if (typeof args[0] === 'string') {
topic = args[1] === undefined ? args[0] : `${args[0]}:${args[1]}`;
}
else {
topic = args[0].id === undefined ? args[0].topic : `${args[0].topic}:${args[0].id}`;
buffer = args[0].buffer;
}
return new repeater_1.Repeater(function subscriptionRepeater(next, stop) {
stop.then(function subscriptionRepeaterStopHandler() {
target.removeEventListener(topic, pubsubEventListener);
});
target.addEventListener(topic, pubsubEventListener);
function pubsubEventListener(event) {
next(event.detail);
}
}, buffer);
}
return {

@@ -16,3 +37,3 @@ publish(routingKey, ...args) {

const topic = args[1] === undefined ? routingKey : `${routingKey}:${args[0]}`;
const event = new CustomEvent(topic, {
const event = new events_1.CustomEvent(topic, {
detail: payload,

@@ -22,16 +43,5 @@ });

},
subscribe(...[routingKey, id]) {
const topic = id === undefined ? routingKey : `${routingKey}:${id}`;
return new repeater_1.Repeater(function subscriptionRepeater(next, stop) {
stop.then(function subscriptionRepeaterStopHandler() {
target.removeEventListener(topic, pubsubEventListener);
});
target.addEventListener(topic, pubsubEventListener);
function pubsubEventListener(event) {
next(event.detail);
}
});
},
subscribe,
};
};
exports.createPubSub = createPubSub;
import { Repeater } from '@repeaterjs/repeater';
import { CustomEvent } from '@whatwg-node/events';
/**

@@ -7,2 +8,22 @@ * Utility for publishing and subscribing to events.

const target = config?.eventTarget ?? new EventTarget();
function subscribe(...args) {
let topic;
let buffer;
if (typeof args[0] === 'string') {
topic = args[1] === undefined ? args[0] : `${args[0]}:${args[1]}`;
}
else {
topic = args[0].id === undefined ? args[0].topic : `${args[0].topic}:${args[0].id}`;
buffer = args[0].buffer;
}
return new Repeater(function subscriptionRepeater(next, stop) {
stop.then(function subscriptionRepeaterStopHandler() {
target.removeEventListener(topic, pubsubEventListener);
});
target.addEventListener(topic, pubsubEventListener);
function pubsubEventListener(event) {
next(event.detail);
}
}, buffer);
}
return {

@@ -17,15 +38,4 @@ publish(routingKey, ...args) {

},
subscribe(...[routingKey, id]) {
const topic = id === undefined ? routingKey : `${routingKey}:${id}`;
return new Repeater(function subscriptionRepeater(next, stop) {
stop.then(function subscriptionRepeaterStopHandler() {
target.removeEventListener(topic, pubsubEventListener);
});
target.addEventListener(topic, pubsubEventListener);
function pubsubEventListener(event) {
next(event.detail);
}
});
},
subscribe,
};
};
{
"name": "@graphql-yoga/subscription",
"version": "5.0.2-alpha-20240728232210-e814a390",
"version": "5.1.0-alpha-20241003102906-3b853548",
"description": "",

@@ -8,2 +8,3 @@ "sideEffects": true,

"@repeaterjs/repeater": "^3.0.4",
"@whatwg-node/events": "^0.1.0",
"tslib": "^2.5.2",

@@ -10,0 +11,0 @@ "@graphql-yoga/typed-event-target": "^3.0.0"

import type { TypedEventTarget } from '@graphql-yoga/typed-event-target';
import { Repeater } from '@repeaterjs/repeater';
import { Repeater, type RepeaterBuffer } from '@repeaterjs/repeater';
type PubSubPublishArgsByKey = {

@@ -26,3 +26,12 @@ [key: string]: [] | [any] | [number | string, any];

*/
subscribe<TKey extends Extract<keyof TPubSubPublishArgsByKey, string>>(...[routingKey, id]: TPubSubPublishArgsByKey[TKey][1] extends undefined ? [TKey] : [TKey, TPubSubPublishArgsByKey[TKey][0]]): Repeater<TPubSubPublishArgsByKey[TKey][1] extends undefined ? MapToNull<TPubSubPublishArgsByKey[TKey][0]> : MapToNull<TPubSubPublishArgsByKey[TKey][1]>>;
subscribe<TKey extends Extract<keyof TPubSubPublishArgsByKey, string>>(...args: (TPubSubPublishArgsByKey[TKey][1] extends undefined ? [key: TKey] : [key: TKey, id: TPubSubPublishArgsByKey[TKey][0]]) | [
args: {
topic: string;
buffer?: RepeaterBuffer | undefined;
} & (TPubSubPublishArgsByKey[TKey][1] extends undefined ? {
id?: void;
} : {
id: TPubSubPublishArgsByKey[TKey][0];
})
]): Repeater<TPubSubPublishArgsByKey[TKey][1] extends undefined ? MapToNull<TPubSubPublishArgsByKey[TKey][0]> : MapToNull<TPubSubPublishArgsByKey[TKey][1]>>;
};

@@ -29,0 +38,0 @@ /**

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