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

@ivfuture/ecomm-event-bus-local

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ivfuture/ecomm-event-bus-local - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

6

dist/services/event-bus-local.d.ts
/// <reference types="node" />
import { Logger, MedusaContainer } from "@ivfuture/ecomm-modules-sdk";
import { EmitData, Subscriber } from "@ivfuture/ecomm-types";
import { MedusaContainer } from "@ivfuture/ecomm-modules-sdk";
import { EmitData, EventBusTypes, Logger, Subscriber } from "@ivfuture/ecomm-types";
import { AbstractEventBusModuleService } from "@ivfuture/ecomm-utils";

@@ -20,4 +20,4 @@ import { EventEmitter } from "events";

subscribe(event: string | symbol, subscriber: Subscriber): this;
unsubscribe(event: string | symbol, subscriber: Subscriber): this;
unsubscribe(event: string | symbol, subscriber: Subscriber, context?: EventBusTypes.SubscriberContext): this;
}
export {};

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

const events_1 = require("events");
const ulid_1 = require("ulid");
const eventEmitter = new events_1.EventEmitter();

@@ -43,2 +44,4 @@ eventEmitter.setMaxListeners(Infinity);

subscribe(event, subscriber) {
const randId = (0, ulid_1.ulid)();
this.storeSubscribers({ event, subscriberId: randId, subscriber });
this.eventEmitter_.on(event, (...args) => __awaiter(this, void 0, void 0, function* () {

@@ -55,3 +58,11 @@ try {

}
unsubscribe(event, subscriber) {
unsubscribe(event, subscriber, context) {
var _a;
const existingSubscribers = this.eventToSubscribersMap_.get(event);
if (existingSubscribers === null || existingSubscribers === void 0 ? void 0 : existingSubscribers.length) {
const subIndex = existingSubscribers === null || existingSubscribers === void 0 ? void 0 : existingSubscribers.findIndex((sub) => sub.id === (context === null || context === void 0 ? void 0 : context.subscriberId));
if (subIndex !== -1) {
(_a = this.eventToSubscribersMap_.get(event)) === null || _a === void 0 ? void 0 : _a.splice(subIndex, 1);
}
}
this.eventEmitter_.off(event, subscriber);

@@ -58,0 +69,0 @@ return this;

{
"name": "@ivfuture/ecomm-event-bus-local",
"version": "1.0.0",
"version": "1.1.0",
"description": "Local Event Bus Module for Medusa",

@@ -20,3 +20,3 @@ "main": "dist/index.js",

"devDependencies": {
"@ivfuture/ecomm-types": "^1.0.0",
"@ivfuture/ecomm-types": "^1.0.1",
"cross-env": "^5.2.1",

@@ -35,5 +35,6 @@ "jest": "^25.5.2",

"dependencies": {
"@ivfuture/ecomm-modules-sdk": "^1.0.0",
"@ivfuture/ecomm-utils": "^1.0.0"
"@ivfuture/ecomm-modules-sdk": "^1.0.1",
"@ivfuture/ecomm-utils": "^1.1.0",
"ulid": "^2.3.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