ts-simple-event-bus
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -1,3 +0,3 @@ | ||
export declare type Message<T = any> = T; | ||
export declare type Subscription<T> = { | ||
export type Message<T = any> = T; | ||
export type Subscription<T> = { | ||
id: string; | ||
@@ -7,4 +7,4 @@ queue: keyof T; | ||
}; | ||
export declare type Callback<T> = (message: Message<T>, id?: string) => void | Promise<void>; | ||
export declare type IdGenerator = () => string; | ||
export type Callback<T> = (message: Message<T>, id?: string) => void | Promise<void>; | ||
export type IdGenerator = () => string; | ||
export declare class MessageTimeoutError extends Error { | ||
@@ -11,0 +11,0 @@ constructor(message?: Message); |
@@ -1,1 +0,18 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["ts-simple-event-bus"]=t():e["ts-simple-event-bus"]=t()}(this,(function(){return(()=>{"use strict";var e={225:function(e,t){var s=this&&this.__awaiter||function(e,t,s,i){return new(s||(s=Promise))((function(r,o){function n(e){try{c(i.next(e))}catch(e){o(e)}}function u(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(n,u)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.EventBus=t.MessageTimeoutError=void 0;class i extends Error{constructor(e){super("Message timeout error"),this.message=`Message timeout error on message ${e}`}}t.MessageTimeoutError=i,t.EventBus=class{constructor(e){this.subcriptions=[],this.idGenerator=e}publish({queue:e,message:t,id:i}){return s(this,void 0,void 0,(function*(){this.subcriptions.forEach((r=>s(this,void 0,void 0,(function*(){r.queue===e&&r.callback(t,i)}))))}))}subscribe({queue:e,callback:t}){const s=this.idGenerator();return this.subcriptions.push({queue:e,callback:t,id:s}),{unsubscribe:()=>{this.subcriptions=this.subcriptions.filter((e=>e.id!==s))}}}publishAndWaitForResponse({message:e,queue:t,responseQueue:s,timeout:r=5e3}){return new Promise(((o,n)=>{const u=this.idGenerator(),c=setTimeout((()=>{n(new i)}),r);this.subscribe({queue:s,callback:(e,t)=>{t===u&&(clearTimeout(c),o(e))}}),this.publish({queue:t,message:e,id:u})}))}}},607:function(e,t,s){var i=this&&this.__createBinding||(Object.create?function(e,t,s,i){void 0===i&&(i=s),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[s]}})}:function(e,t,s,i){void 0===i&&(i=s),e[i]=t[s]}),r=this&&this.__exportStar||function(e,t){for(var s in e)"default"===s||Object.prototype.hasOwnProperty.call(t,s)||i(t,e,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(s(225),t)}},t={};return function s(i){var r=t[i];if(void 0!==r)return r.exports;var o=t[i]={exports:{}};return e[i].call(o.exports,o,o.exports,s),o.exports}(607)})()})); | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./bus"), exports); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "ts-simple-event-bus", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"main": "dist/index.js", | ||
@@ -21,4 +21,3 @@ "types": "dist/index.d.ts", | ||
"@types/mocha": "^9.0.0", | ||
"@typescript-eslint/eslint-plugin": "^4.11.0", | ||
"@typescript-eslint/parser": "^4.11.0", | ||
"@types/node": "^20.10.7", | ||
"chai": "^4.3.4", | ||
@@ -28,14 +27,7 @@ "chai-as-promised": "^7.1.1", | ||
"coveralls": "^3.1.1", | ||
"eslint-config-prettier": "^7.1.0", | ||
"eslint-plugin-prettier": "^3.3.0", | ||
"mocha": "^9.1.3", | ||
"nanoid": "^3.3.2", | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.2.1", | ||
"ts-loader": "^9.2.6", | ||
"ts-node-dev": "^1.1.1", | ||
"typescript": "^4.5.2", | ||
"webpack": "^5.65.0", | ||
"webpack-cli": "^4.9.1", | ||
"webpack-dev-server": "^4.6.0" | ||
"typescript": "^5.3.3" | ||
}, | ||
@@ -42,0 +34,0 @@ "nyc": { |
@@ -6,4 +6,2 @@ { | ||
"removeComments": true, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"allowSyntheticDefaultImports": true, | ||
@@ -10,0 +8,0 @@ "target": "es6", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26349
15
17
465