Skip to content

Commit 8e6003b

Browse files
committed
Fixed exports and version numbers
1 parent 7320ef9 commit 8e6003b

File tree

4 files changed

+4
-11
lines changed

4 files changed

+4
-11
lines changed

dist/publisher.min.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
* @author Frank Kudermann / alphanull
1111
* @version 1.6.0
1212
* @license MIT
13-
*/var n={configure:a,publish:u,subscribe:l,unsubscribe:p,removePersistentMessage:d};const i={async:!0,handleExceptions:!1,lenientUnsubscribe:!1};let t=-1;const o=new Map,s=new Map,r=new Map;function c(e){"function"==typeof queueMicrotask?queueMicrotask(e):"function"==typeof Promise?Promise.resolve().then(e):setTimeout(e,0)}function f(e){return void 0===e}function a({async:e,handleExceptions:n,lenientUnsubscribe:t}={}){f(e)||(i.async=e),f(n)||(i.handleExceptions=n),f(t)||(i.lenientUnsubscribe=t)}function u(e,n,t={}){if(!0===t.persist&&r.set(e,{data:n,options:t}),e.indexOf("*")>-1)throw new Error("Publish topic cannot contain any wildcards.");const o=h(e.split("/"),n,t,s,e);let a;o.sort(((e,n)=>e.priority===n.priority?e.position-n.position:e.priority>n.priority?-1:1));const u=f(t.async)?i.async:t.async;for(;a=o.shift();)if(u)c(b.bind(null,a,e,n,t));else if(!1===b(a,e,n,t)&&!1!==t.cancelable)return!1;return!0}function l(e,n,a={}){const u=t+=1;if(f(e))throw new Error("Subscribe failed - undefined Topic.");if(e.includes("undefined"))throw new Error(`Subscribe for '${e}' failed - found 'undefined' in topic, this is almost always an error: ${u}`);if(f(n))throw new Error(`Subscribe for '${e}' failed - undefined Handler`);const l={token:u,topic:e,handler:n,options:a};if(o.set(u,l),g(e.split("/"),l,s),!0!==a.persist)return u;const p=new RegExp(`^${e.replace("*","(.+)")}(/.+)?$`);for(const[e,n]of r){if(e.match(p)){if(f(n.options.async)?i.async:n.options.async)c(b.bind(null,l,e,n.data,a));else if(!1===b(l,e,n.data,a)&&!0===a.cancelable)break}}return u}function p(e,n,t){const r=n===Boolean(n)?n:t,c=f(r)?i.lenientUnsubscribe:r,a=e=>{const n=o.get(e);if(f(n)){if(!0===c)return;throw new Error(`Unsubscribe failed. Did not find subscriber for token: ${e}`)}w(n.topic.split("/"),n,s),o.delete(e)};if(f(e)){if(!0===c)return;throw new Error("Unsubscribe failed. No Arguments specified.")}if(Array.isArray(e))e.forEach((e=>a(e)));else if(!isNaN(parseFloat(e))&&isFinite(e))a(e);else{if(f(n)){if(!0===c)return;throw new Error(`Unsubscribe failed. No handler for topic based unsubscribe specified ${e}`)}for(const[,i]of o)if(i.handler===n&&i.topic===e){w(e.split("/"),i,s),o.delete(i.token);break}}}function d(e){r.delete(e)}function b(e,n,t,s={}){if(!o.has(e.token))return;e.options.invocations>0&&(e.options.invocations-=1,e.options.invocations<1&&p(e.token));const{handler:r}=e;if(!0!==s.handleExceptions&&!0!==i.handleExceptions)return!0===e.options.topicArg?r(n,t):r(t,n);try{return!0===e.options.topicArg?r(n,t):r(t,n)}catch(e){window.console&&window.console.error&&window.console.error("Exception while executing publish handler: ",e)}}function h(e,n,t={},o,s,r=[]){const c=o.get("subscribers")||new Map,a=o.get("topics");for(const[,e]of c){const{condition:o,topicArg:c}=e.options;(f(o)||(!0===c?!0===o(s,n):!0===o(n,s)))&&(e.position=r.push(e),e.priority=e.options.priority||0,e.async=Boolean(t.async||e.options.async||i.async))}if(e.length&&a){const i=a.get(e[0]),o=a.get("*");f(o)&&f(i)||(f(o)||h(e.slice(1,e.length),n,t,o,s,r),f(i)||h(e.slice(1,e.length),n,t,i,s,r),e.shift())}return r}function g(e,n,i){const[t]=e;f(i.get("topics"))&&i.set("topics",new Map);const o=i.get("topics");let s=o.get(t);f(s)&&(s=new Map,o.set(t,s)),e.length<2?(f(s.get("subscribers"))&&s.set("subscribers",new Map),s.get("subscribers").set(n.token,n)):(e.shift(),g(e,n,s))}function w(e,n,i){const[t]=e,o=i.get("topics"),s=o.get(t),r=s.get("subscribers");e.length<2?(r.delete(n.token),0===r.size&&s.delete("subscribers")):(e.shift(),w(e,n,s)),s.has("topics")&&0===s.get("topics").size&&s.delete("topics"),0===o.get(t).size&&o.delete(t)}e.configure=a,e.default=n,e.publish=u,e.removePersistentMessage=d,e.subscribe=l,e.unsubscribe=p,Object.defineProperty(e,"__esModule",{value:!0})}));
13+
*/const n={async:!0,handleExceptions:!1,lenientUnsubscribe:!1};let i=-1;const t=new Map,o=new Map,s=new Map;function r(e){"function"==typeof queueMicrotask?queueMicrotask(e):"function"==typeof Promise?Promise.resolve().then(e):setTimeout(e,0)}function c(e){return void 0===e}function f(e,i,s){const r=i===Boolean(i)?i:s,f=c(r)?n.lenientUnsubscribe:r,a=e=>{const n=t.get(e);if(c(n)){if(!0===f)return;throw new Error(`Unsubscribe failed. Did not find subscriber for token: ${e}`)}u(n.topic.split("/"),n,o),t.delete(e)};if(c(e)){if(!0===f)return;throw new Error("Unsubscribe failed. No Arguments specified.")}if(Array.isArray(e))e.forEach((e=>a(e)));else if(!isNaN(parseFloat(e))&&isFinite(e))a(e);else{if(c(i)){if(!0===f)return;throw new Error(`Unsubscribe failed. No handler for topic based unsubscribe specified ${e}`)}for(const[,n]of t)if(n.handler===i&&n.topic===e){u(e.split("/"),n,o),t.delete(n.token);break}}}function a(e,i,o,s={}){if(!t.has(e.token))return;e.options.invocations>0&&(e.options.invocations-=1,e.options.invocations<1&&f(e.token));const{handler:r}=e;if(!0!==s.handleExceptions&&!0!==n.handleExceptions)return!0===e.options.topicArg?r(i,o):r(o,i);try{return!0===e.options.topicArg?r(i,o):r(o,i)}catch(e){window.console&&window.console.error&&window.console.error("Exception while executing publish handler: ",e)}}function l(e,i,t={},o,s,r=[]){const f=o.get("subscribers")||new Map,a=o.get("topics");for(const[,e]of f){const{condition:o,topicArg:f}=e.options;(c(o)||(!0===f?!0===o(s,i):!0===o(i,s)))&&(e.position=r.push(e),e.priority=e.options.priority||0,e.async=Boolean(t.async||e.options.async||n.async))}if(e.length&&a){const n=a.get(e[0]),o=a.get("*");c(o)&&c(n)||(c(o)||l(e.slice(1,e.length),i,t,o,s,r),c(n)||l(e.slice(1,e.length),i,t,n,s,r),e.shift())}return r}function p(e,n,i){const[t]=e;c(i.get("topics"))&&i.set("topics",new Map);const o=i.get("topics");let s=o.get(t);c(s)&&(s=new Map,o.set(t,s)),e.length<2?(c(s.get("subscribers"))&&s.set("subscribers",new Map),s.get("subscribers").set(n.token,n)):(e.shift(),p(e,n,s))}function u(e,n,i){const[t]=e,o=i.get("topics"),s=o.get(t),r=s.get("subscribers");e.length<2?(r.delete(n.token),0===r.size&&s.delete("subscribers")):(e.shift(),u(e,n,s)),s.has("topics")&&0===s.get("topics").size&&s.delete("topics"),0===o.get(t).size&&o.delete(t)}e.configure=function({async:e,handleExceptions:i,lenientUnsubscribe:t}={}){c(e)||(n.async=e),c(i)||(n.handleExceptions=i),c(t)||(n.lenientUnsubscribe=t)},e.publish=function(e,i,t={}){if(!0===t.persist&&s.set(e,{data:i,options:t}),e.indexOf("*")>-1)throw new Error("Publish topic cannot contain any wildcards.");const f=l(e.split("/"),i,t,o,e);let p;f.sort(((e,n)=>e.priority===n.priority?e.position-n.position:e.priority>n.priority?-1:1));const u=c(t.async)?n.async:t.async;for(;p=f.shift();)if(u)r(a.bind(null,p,e,i,t));else if(!1===a(p,e,i,t)&&!1!==t.cancelable)return!1;return!0},e.removePersistentMessage=function(e){s.delete(e)},e.subscribe=function(e,f,l={}){const u=i+=1;if(c(e))throw new Error("Subscribe failed - undefined Topic.");if(e.includes("undefined"))throw new Error(`Subscribe for '${e}' failed - found 'undefined' in topic, this is almost always an error: ${u}`);if(c(f))throw new Error(`Subscribe for '${e}' failed - undefined Handler`);const d={token:u,topic:e,handler:f,options:l};if(t.set(u,d),p(e.split("/"),d,o),!0!==l.persist)return u;const b=new RegExp(`^${e.replace("*","(.+)")}(/.+)?$`);for(const[e,i]of s){if(e.match(b)){if(c(i.options.async)?n.async:i.options.async)r(a.bind(null,d,e,i.data,l));else if(!1===a(d,e,i.data,l)&&!0===l.cancelable)break}}return u},e.unsubscribe=f}));

dist/publisher.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@alphanull/publisher",
33
"license": "MIT",
4-
"version": "1.6.1",
4+
"version": "1.6.2",
55
"description": "Publisher is a JavaScript publish/subscribe library with many features, including: topic hierarchies, sync/async, priority, conditions, wildcards, persistent messages & more.",
66
"keywords": [
77
"publisher",

src/publisher.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,9 @@
22
* The publisher module. Provides pub/sub functionality with extensive wildcard support, async/sync publishing, priority and invocation options, content based filtering & more.
33
* @module publisher
44
* @author Frank Kudermann / alphanull
5-
* @version 1.6.0
5+
* @version 1.6.2
66
* @license MIT
77
*/
8-
export default {
9-
configure,
10-
publish,
11-
subscribe,
12-
unsubscribe,
13-
removePersistentMessage
14-
};
158

169
/* INTERNAL PROPERTIES */
1710

0 commit comments

Comments
 (0)