ts-simple-event-bus
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["ts-event-bus"]=t():e["ts-event-bus"]=t()}(this,(function(){return(()=>{"use strict";var e={225:function(e,t){var s=this&&this.__awaiter||function(e,t,s,r){return new(s||(s=Promise))((function(i,o){function n(e){try{c(r.next(e))}catch(e){o(e)}}function u(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(n,u)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.EventBus=t.MessageTimeoutError=void 0;class r extends Error{constructor(e){super("Message timeout error"),this.message=`Message timeout error on message ${e}`}}t.MessageTimeoutError=r,t.EventBus=class{constructor(e){this.subcriptions=[],this.idGenerator=e}publish({queue:e,message:t,id:r}){return s(this,void 0,void 0,(function*(){this.subcriptions.forEach((i=>s(this,void 0,void 0,(function*(){i.queue===e&&i.callback(t,r)}))))}))}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:i=5e3}){return new Promise(((o,n)=>{const u=this.idGenerator(),c=setTimeout((()=>{n(new r)}),i);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 r=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[s]}})}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),i=this&&this.__exportStar||function(e,t){for(var s in e)"default"===s||Object.prototype.hasOwnProperty.call(t,s)||r(t,e,s)};Object.defineProperty(t,"__esModule",{value:!0}),i(s(225),t)}},t={};return function s(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,s),o.exports}(607)})()})); | ||
!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)})()})); |
{ | ||
"name": "ts-simple-event-bus", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
# TS-simple-event-bus | ||
![npm](https://img.shields.io/npm/v/ts-simple-event-bus) | ||
@@ -3,0 +4,0 @@ A simple event bus that implements a pub / sub pattern. Fully typed. |
@@ -10,3 +10,3 @@ const path = require('path'); | ||
path: path.resolve(__dirname, 'dist'), | ||
library: "ts-event-bus", | ||
library: "ts-simple-event-bus", | ||
libraryTarget: 'umd', | ||
@@ -13,0 +13,0 @@ globalObject: "this", |
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
107
15588
13
309