You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@hexworks/cobalt-events

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hexworks/cobalt-events - npm Package Compare versions

Comparing version

to
2023.41.0-RELEASE

4

package.json
{
"name": "@hexworks/cobalt-events",
"version": "2023.40.0-RELEASE",
"version": "2023.41.0-RELEASE",
"description": "Event bus implementation for Cobalt.",

@@ -28,3 +28,3 @@ "homepage": "https://github.com/Hexworks/cobalt-ts",

"immutable": "^4.3.0",
"@hexworks/cobalt-core": "2023.40.0-RELEASE",
"@hexworks/cobalt-core": "2023.41.0-RELEASE",
"tslib": "^2.5.0"

@@ -31,0 +31,0 @@ },

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SubscriptionOption = void 0;
exports.SubscriptionOption = {
export const SubscriptionOption = {
Keep: "Keep",

@@ -6,0 +3,0 @@ Cancel: "Cancel",

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventPublishingError = void 0;
const cobalt_core_1 = require("@hexworks/cobalt-core");
class EventPublishingError extends cobalt_core_1.ProgramErrorBase {
import { ProgramErrorBase } from "@hexworks/cobalt-core";
export class EventPublishingError extends ProgramErrorBase {
errors;

@@ -15,3 +12,2 @@ constructor(errors) {

}
exports.EventPublishingError = EventPublishingError;
//# sourceMappingURL=EventPublishingError.js.map

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./EventPublishingError"), exports);
export * from "./EventPublishingError";
//# sourceMappingURL=index.js.map

@@ -1,3 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export {};
//# sourceMappingURL=Event.js.map

@@ -1,8 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventBus = exports.DEFAULT_EVENT_SCOPE = void 0;
const internal_1 = require("../internal");
exports.DEFAULT_EVENT_SCOPE = "DEFAULT_EVENT_SCOPE";
const EventBus = ({ idProvider }) => new internal_1.DefaultEventBus(idProvider);
exports.EventBus = EventBus;
import { DefaultEventBus } from "../internal";
export const DEFAULT_EVENT_SCOPE = "DEFAULT_EVENT_SCOPE";
export const EventBus = ({ idProvider }) => new DefaultEventBus(idProvider);
//# sourceMappingURL=EventBus.js.map

@@ -1,8 +0,5 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./Event"), exports);
tslib_1.__exportStar(require("./EventBus"), exports);
tslib_1.__exportStar(require("./Subscription"), exports);
tslib_1.__exportStar(require("./CallbackResult"), exports);
export * from "./Event";
export * from "./EventBus";
export * from "./Subscription";
export * from "./CallbackResult";
//# sourceMappingURL=index.js.map

@@ -1,3 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export {};
//# sourceMappingURL=Subscription.js.map

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./api"), exports);
export * from "./api";
//# sourceMappingURL=index.js.map

@@ -1,16 +0,12 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultEventBus = void 0;
const tslib_1 = require("tslib");
const A = tslib_1.__importStar(require("fp-ts/Array"));
const T = tslib_1.__importStar(require("fp-ts/Task"));
const TE = tslib_1.__importStar(require("fp-ts/TaskEither"));
const function_1 = require("fp-ts/function");
const immutable_1 = require("immutable");
const api_1 = require("../api");
const errors_1 = require("../api/errors");
const EMPTY_SCOPE = (0, immutable_1.Map)();
const NO_SUBSCRIBERS = (0, immutable_1.List)();
class DefaultEventBus {
subscriptions = (0, immutable_1.Map)();
import * as A from "fp-ts/Array";
import * as T from "fp-ts/Task";
import * as TE from "fp-ts/TaskEither";
import { identity, pipe } from "fp-ts/function";
import { List, Map } from "immutable";
import { DEFAULT_EVENT_SCOPE, } from "../api";
import { EventPublishingError } from "../api/errors";
const EMPTY_SCOPE = Map();
const NO_SUBSCRIBERS = List();
export class DefaultEventBus {
subscriptions = Map();
idProvider;

@@ -20,3 +16,3 @@ constructor(idProvider) {

}
fetchSubscribersOf(type, scope = api_1.DEFAULT_EVENT_SCOPE) {
fetchSubscribersOf(type, scope = DEFAULT_EVENT_SCOPE) {
return this.getSubsriptionsBy(scope, type).map((s) => {

@@ -28,3 +24,3 @@ // eslint-disable-next-line @typescript-eslint/no-unused-vars

}
subscribe(type, fn, scope = api_1.DEFAULT_EVENT_SCOPE) {
subscribe(type, fn, scope = DEFAULT_EVENT_SCOPE) {
const id = this.idProvider.generateId();

@@ -45,3 +41,3 @@ const subscription = {

}
publish(event, scope = api_1.DEFAULT_EVENT_SCOPE) {
publish(event, scope = DEFAULT_EVENT_SCOPE) {
const { type } = event;

@@ -51,3 +47,3 @@ const results = this.getSubsriptionsBy(scope, type)

const { fn, id } = subscription;
return (0, function_1.pipe)(fn(event), TE.map((result) => {
return pipe(fn(event), TE.map((result) => {
if (result.subscription === "Cancel") {

@@ -63,3 +59,3 @@ this.cancelSubscription({

.toArray();
return (0, function_1.pipe)(results, A.map(TE.bimap((e) => [e], function_1.identity)), A.sequence(TE.getApplicativeTaskValidation(T.ApplyPar, A.getSemigroup())), TE.map(() => undefined), TE.mapLeft((e) => new errors_1.EventPublishingError(e)));
return pipe(results, A.map(TE.bimap((e) => [e], identity)), A.sequence(TE.getApplicativeTaskValidation(T.ApplyPar, A.getSemigroup())), TE.map(() => undefined), TE.mapLeft((e) => new EventPublishingError(e)));
}

@@ -78,3 +74,2 @@ cancelScope(scope) {

}
exports.DefaultEventBus = DefaultEventBus;
//# sourceMappingURL=DefaultEventBus.js.map

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./DefaultEventBus"), exports);
export * from "./DefaultEventBus";
//# sourceMappingURL=index.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet